Skip to content

Commit fe8c4d6

Browse files
Better fix #2660
1 parent 31dbbb0 commit fe8c4d6

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

dbms/src/Parsers/ExpressionElementParsers.cpp

+13
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
#include <errno.h>
22
#include <cstdlib>
33

4+
#include <Poco/String.h>
5+
46
#include <IO/ReadHelpers.h>
57
#include <IO/ReadBufferFromMemory.h>
68

@@ -236,6 +238,17 @@ bool ParserFunction::parseImpl(Pos & pos, ASTPtr & node, Expected & expected)
236238
, ErrorCodes::SYNTAX_ERROR);
237239
}
238240

241+
/// Temporary compatibility fix for Yandex.Metrika.
242+
/// When we have a query with
243+
/// cast(x, 'Type')
244+
/// when cast is not in uppercase and when expression is written as a function, not as operator like cast(x AS Type)
245+
/// and newer ClickHouse server (1.1.54388) interacts with older ClickHouse server (1.1.54381) in distributed query,
246+
/// then exception was thrown.
247+
248+
auto & identifier_concrete = typeid_cast<ASTIdentifier &>(*identifier);
249+
if (Poco::toLower(identifier_concrete.name) == "cast")
250+
identifier_concrete.name = "CAST";
251+
239252
/// The parametric aggregate function has two lists (parameters and arguments) in parentheses. Example: quantile(0.9)(x).
240253
if (pos->type == TokenType::OpeningRoundBracket)
241254
{

0 commit comments

Comments
 (0)