From 7b69592e496b2ad8cc5ac75dc408e0030c88f8ed Mon Sep 17 00:00:00 2001 From: feng lv Date: Wed, 14 Oct 2020 23:08:47 +0800 Subject: [PATCH] add test fix fix --- src/Parsers/ExpressionListParsers.cpp | 9 ++++----- ...23_interval_operator_support_string_literal.reference | 6 ++++++ .../01523_interval_operator_support_string_literal.sql | 6 ++++++ 3 files changed, 16 insertions(+), 5 deletions(-) create mode 100644 tests/queries/0_stateless/01523_interval_operator_support_string_literal.reference create mode 100644 tests/queries/0_stateless/01523_interval_operator_support_string_literal.sql diff --git a/src/Parsers/ExpressionListParsers.cpp b/src/Parsers/ExpressionListParsers.cpp index ab1f7abf4a1..4f4b97eff2d 100644 --- a/src/Parsers/ExpressionListParsers.cpp +++ b/src/Parsers/ExpressionListParsers.cpp @@ -670,14 +670,14 @@ bool ParserIntervalOperatorExpression::parseImpl(Pos & pos, ASTPtr & node, Expec IntervalKind interval_kind; ASTPtr number; + /// parse function arguments and interval kind from string literal if (!stringToIntervalKind(literal, number, interval_kind)) return false; + auto function = std::make_shared(); - /// function arguments auto exp_list = std::make_shared(); - /// the first argument of the function is the previous element, the second is the next one function->name = interval_kind.toNameOfFunctionToIntervalDataType(); function->arguments = exp_list; function->children.push_back(exp_list); @@ -690,12 +690,11 @@ bool ParserIntervalOperatorExpression::parseImpl(Pos & pos, ASTPtr & node, Expec } ASTPtr expr; - /// Any expression can be inside, because operator surrounds it. if (!ParserExpressionWithOptionalAlias(false).parse(pos, expr, expected)) { - pos = begin; - return next_parser.parse(pos, node, expected); + pos = begin; + return next_parser.parse(pos, node, expected); } IntervalKind interval_kind; diff --git a/tests/queries/0_stateless/01523_interval_operator_support_string_literal.reference b/tests/queries/0_stateless/01523_interval_operator_support_string_literal.reference new file mode 100644 index 00000000000..5ee4e7592f6 --- /dev/null +++ b/tests/queries/0_stateless/01523_interval_operator_support_string_literal.reference @@ -0,0 +1,6 @@ +2 +2 +2 +2 +2 +2 diff --git a/tests/queries/0_stateless/01523_interval_operator_support_string_literal.sql b/tests/queries/0_stateless/01523_interval_operator_support_string_literal.sql new file mode 100644 index 00000000000..ce418e13e9f --- /dev/null +++ b/tests/queries/0_stateless/01523_interval_operator_support_string_literal.sql @@ -0,0 +1,6 @@ +SELECT INTERVAL 2 day; +SELECT INTERVAL '2 day'; +SELECT INTERVAL 2 hour; +SELECT INTERVAL '2 hour'; +SELECT INTERVAL 2 minute; +SELECT INTERVAL '2 minute';