When using a foreign table (e.g. a mysql table) clickhouse doesn't seem to properly send the result of functions if they are called inside `WHERE` statements.

Executing `SELECT foo FROM foreign_table WHERE a=10 AND b='2019-10-05'` will send a statement like:

```
SELECT `foo`, `a`, `b` FROM `db`.`foreign_table`  WHERE (`a` = 10) AND (`b` = '2019-10-05')
```

But executing `SELECT foo FROM foreign_table WHERE a=10 AND b=toDate('2019-10-05')` will send:

```
SELECT `foo`, `a`, `b` FROM `db`.`foreign_table`  WHERE (`a` = 10)
```

I assume that the function is executed afterwards and `b` is parsed clickhouse-side.

I'm not sure if there is an easy fix for this, but I assume this would help with the efficiency of mysql foreign tables and might be critical in some high-load scenarios where one wants to filter on indexed columns.

My specific issue here is different and relates to the clickhouse mindsdb integration, but I think this "bug" (if you'd call it such) is more generic.
{
    const State & state = State::instance();
    check(state, 1,
          "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)))");
}
TEST(TransformQueryForExternalDatabase, Aliases)
{
    const State & state = State::instance();
    check(state, 1,
          "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%'))");
}
TEST(TransformQueryForExternalDatabase, ForeignColumnInWhere)
{
    const State & state = State::instance();
    check(state, 2,
          "SELECT column FROM test.table "
          "JOIN test.table2 AS table2 ON (test.table.apply_id = table2.num) "
          "WHERE column > 2 AND (apply_id = 1 OR table2.num = 1) AND table2.attr != ''",
          R"(SELECT "column", "apply_id" FROM "test"."table" WHERE ("column" > 2) AND ("apply_id" = 1))");
}
TEST(TransformQueryForExternalDatabase, NoStrict)