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,
    size_t table_num,
    const std::string & query,
    const std::string & expected)
{
    ParserSelectQuery parser;
    ASTPtr ast = parseQuery(parser, query, 1000, 1000);
    SelectQueryInfo query_info;
    SelectQueryOptions select_options;
    query_info.syntax_analyzer_result
        = TreeRewriter(state.context).analyzeSelect(ast, DB::TreeRewriterResult(state.getColumns()), select_options, state.getTables(table_num));
    query_info.query = ast;
    std::string transformed_query = transformQueryForExternalDatabase(
        query_info, state.getColumns(), IdentifierQuotingStyle::DoubleQuotes, "test", "table", state.context);
    EXPECT_EQ(transformed_query, expected) << query;
}
TEST(TransformQueryForExternalDatabase, InWithSingleElement)
{
    const State & state = State::instance();
    check(state, 1,
          "SELECT column FROM test.table WHERE 1 IN (1)",
          R"(SELECT "column" FROM "test"."table" WHERE 1 = 1)");
    check(state, 1,
          "SELECT column FROM test.table WHERE column IN (1, 2)",
          R"(SELECT "column" FROM "test"."table" WHERE "column" IN (1, 2))");
    check(state, 1,
          "SELECT column FROM test.table WHERE column NOT IN ('hello', 'world')",
          R"(SELECT "column" FROM "test"."table" WHERE "column" NOT IN ('hello', 'world'))");
}
TEST(TransformQueryForExternalDatabase, InWithMultipleColumns)