From fe8c4d64e434cacd4ceef34faa9005129f2190a5 Mon Sep 17 00:00:00 2001 From: Alexey Milovidov Date: Thu, 19 Jul 2018 23:51:03 +0300 Subject: [PATCH] Better fix #2660 --- dbms/src/Parsers/ExpressionElementParsers.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/dbms/src/Parsers/ExpressionElementParsers.cpp b/dbms/src/Parsers/ExpressionElementParsers.cpp index 9a199a6839ef..7595d3044c9e 100644 --- a/dbms/src/Parsers/ExpressionElementParsers.cpp +++ b/dbms/src/Parsers/ExpressionElementParsers.cpp @@ -1,6 +1,8 @@ #include #include +#include + #include #include @@ -236,6 +238,17 @@ bool ParserFunction::parseImpl(Pos & pos, ASTPtr & node, Expected & expected) , ErrorCodes::SYNTAX_ERROR); } + /// Temporary compatibility fix for Yandex.Metrika. + /// When we have a query with + /// cast(x, 'Type') + /// when cast is not in uppercase and when expression is written as a function, not as operator like cast(x AS Type) + /// and newer ClickHouse server (1.1.54388) interacts with older ClickHouse server (1.1.54381) in distributed query, + /// then exception was thrown. + + auto & identifier_concrete = typeid_cast(*identifier); + if (Poco::toLower(identifier_concrete.name) == "cast") + identifier_concrete.name = "CAST"; + /// The parametric aggregate function has two lists (parameters and arguments) in parentheses. Example: quantile(0.9)(x). if (pos->type == TokenType::OpeningRoundBracket) {