Skip to content

Commit

Permalink
Better fix #2660
Browse files Browse the repository at this point in the history
  • Loading branch information
alexey-milovidov committed Jul 19, 2018
1 parent 31dbbb0 commit fe8c4d6
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions dbms/src/Parsers/ExpressionElementParsers.cpp
@@ -1,6 +1,8 @@
#include <errno.h>
#include <cstdlib>

#include <Poco/String.h>

#include <IO/ReadHelpers.h>
#include <IO/ReadBufferFromMemory.h>

Expand Down Expand Up @@ -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<ASTIdentifier &>(*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)
{
Expand Down

0 comments on commit fe8c4d6

Please sign in to comment.