fix

fix
This commit is contained in:
feng lv 2020-10-14 23:08:47 +08:00
parent eb8d8f6ba4
commit 7b69592e49
3 changed files with 16 additions and 5 deletions

View File

@ -670,14 +670,14 @@ bool ParserIntervalOperatorExpression::parseImpl(Pos & pos, ASTPtr & node, Expec
IntervalKind interval_kind; IntervalKind interval_kind;
ASTPtr number; ASTPtr number;
/// parse function arguments and interval kind from string literal
if (!stringToIntervalKind(literal, number, interval_kind)) if (!stringToIntervalKind(literal, number, interval_kind))
return false; return false;
auto function = std::make_shared<ASTFunction>(); auto function = std::make_shared<ASTFunction>();
/// function arguments
auto exp_list = std::make_shared<ASTExpressionList>(); auto exp_list = std::make_shared<ASTExpressionList>();
/// the first argument of the function is the previous element, the second is the next one
function->name = interval_kind.toNameOfFunctionToIntervalDataType(); function->name = interval_kind.toNameOfFunctionToIntervalDataType();
function->arguments = exp_list; function->arguments = exp_list;
function->children.push_back(exp_list); function->children.push_back(exp_list);
@ -690,12 +690,11 @@ bool ParserIntervalOperatorExpression::parseImpl(Pos & pos, ASTPtr & node, Expec
} }
ASTPtr expr; ASTPtr expr;
/// Any expression can be inside, because operator surrounds it. /// Any expression can be inside, because operator surrounds it.
if (!ParserExpressionWithOptionalAlias(false).parse(pos, expr, expected)) if (!ParserExpressionWithOptionalAlias(false).parse(pos, expr, expected))
{ {
pos = begin; pos = begin;
return next_parser.parse(pos, node, expected); return next_parser.parse(pos, node, expected);
} }
IntervalKind interval_kind; IntervalKind interval_kind;

View File

@ -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';