diff --git a/dbms/src/Parsers/ExpressionElementParsers.cpp b/dbms/src/Parsers/ExpressionElementParsers.cpp index fa43d5fba01..34198b58fd5 100644 --- a/dbms/src/Parsers/ExpressionElementParsers.cpp +++ b/dbms/src/Parsers/ExpressionElementParsers.cpp @@ -300,6 +300,8 @@ bool ParserCastExpression::parseImpl(Pos & pos, ASTPtr & node, Expected & expect return false; const auto & id = typeid_cast(*identifier).name; + + /// TODO This is ridiculous. Please get rid of this. if (id.length() != strlen(name) || 0 != strcasecmp(id.c_str(), name)) { /// Parse as a CASE expression. @@ -340,6 +342,8 @@ bool ParserCastExpression::parseImpl(Pos & pos, ASTPtr & node, Expected & expect } else { + pos = contents_begin; + /// CAST(expression, 'type') /// Reparse argument list from scratch ParserExpressionWithOptionalAlias expression{false}; diff --git a/dbms/tests/queries/0_stateless/00483_cast_syntax.reference b/dbms/tests/queries/0_stateless/00483_cast_syntax.reference new file mode 100644 index 00000000000..6ed281c757a --- /dev/null +++ b/dbms/tests/queries/0_stateless/00483_cast_syntax.reference @@ -0,0 +1,2 @@ +1 +1 diff --git a/dbms/tests/queries/0_stateless/00483_cast_syntax.sql b/dbms/tests/queries/0_stateless/00483_cast_syntax.sql new file mode 100644 index 00000000000..be248fce394 --- /dev/null +++ b/dbms/tests/queries/0_stateless/00483_cast_syntax.sql @@ -0,0 +1,2 @@ +SELECT CAST(1 AS Int8); +SELECT CAST(1, 'Int8');