table A:
![image](https://user-images.githubusercontent.com/17606375/105842341-f9b40580-6010-11eb-8507-6ea46fe814c8.png)
table B:
![image](https://user-images.githubusercontent.com/17606375/105842364-0173aa00-6011-11eb-94a3-47c162dd40fd.png)

select 
  "T_8FB5CF"."id1" "__fcol_0", 
  "T_8FB5CF"."id2" "__fcol_1", 
  "T_8FB5CF"."id3" "__fcol_2", 
  "T_8FB5CF"."id4" "__fcol_3", 
  "T_8FB5CF"."id5" "__fcol_4", 
  "T_8FB5CF"."date" "__fcol_5", 
  "T_8FB5CF"."shuzhi" "__fcol_6", 
  "T_8FB5CF"."数值2" "__fcol_7"
from "A1"."B" "T_8FB5CF"
  left outer join "A1"."A" "T_8C7546"
  on "T_8FB5CF"."id2" = "T_8C7546"."id2"
where (
  "T_8C7546"."id2" = ''
  or "T_8C7546"."id2" is null
)
limit 5000
ClickHouse exception, code: 47, host: 192.168.5.67, port: 8123; Code: 47, e.displayText() = DB::Exception: Missing columns: 'T_8C7546.id2' while processing query: '(T_8C7546.id2 = '') OR isNull(T_8C7546.id2)', required columns: 'T_8C7546.id2', source columns: '数值2' 'shuzhi' 'date' 'id5' 'id3' 'id2' 'id4' 'id1' (version 20.5.4.40)
{
    const State & state = State::instance();
    check("SELECT column FROM test.table WHERE 1 = 1 AND toString(column) = '42' AND column = 42 AND left(column, 10) = RIGHT(column, 10) AND column IN (1, 42) AND SUBSTRING(column FROM 1 FOR 2) = 'Hello' AND column != 4",
          R"(SELECT "column" FROM "test"."table" WHERE 1 AND ("column" = 42) AND ("column" IN (1, 42)) AND ("column" != 4))",
          state.context, state.columns);
    check("SELECT column FROM test.table WHERE toString(column) = '42' AND left(column, 10) = RIGHT(column, 10) AND column = 42",
          R"(SELECT "column" FROM "test"."table" WHERE ("column" = 42))",
          state.context, state.columns);
}
TEST(TransformQueryForExternalDatabase, Issue7245)
{
    const State & state = State::instance();
    check("select apply_id from test.table where apply_type = 2 and create_time > addDays(toDateTime('2019-01-01 01:02:03'),-7) and apply_status in (3,4)",
          R"(SELECT "apply_id", "apply_type", "apply_status", "create_time" FROM "test"."table" WHERE ("apply_type" = 2) AND ("create_time" > '2018-12-25 01:02:03') AND ("apply_status" IN (3, 4)))",
          state.context, state.columns);
}
TEST(TransformQueryForExternalDatabase, Aliases)
{
    const State & state = State::instance();
    check("SELECT field AS value, field AS display WHERE field NOT IN ('') AND display LIKE '%test%'",
          R"(SELECT "field" FROM "test"."table" WHERE ("field" NOT IN ('')) AND ("field" LIKE '%test%'))",
          state.context, state.columns);
}