From b0cc455c89f193447ea4c7d5756a85560e3f5177 Mon Sep 17 00:00:00 2001 From: "jie.wang" <38901892+jievince@users.noreply.github.com> Date: Wed, 14 Apr 2021 23:36:36 +0800 Subject: [PATCH] Fix date function crash (#943) * fix date() crash * use simple regex in the expected result of tck Co-authored-by: Yee <2520865+yixinglu@users.noreply.github.com> --- src/parser/parser.yy | 10 ++-------- tests/tck/features/expression/FunctionCall.feature | 10 ++++++++++ 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/parser/parser.yy b/src/parser/parser.yy index 36d98cdb..b2b257b6 100644 --- a/src/parser/parser.yy +++ b/src/parser/parser.yy @@ -869,13 +869,7 @@ edge_prop_expression function_call_expression : LABEL L_PAREN opt_argument_list R_PAREN { - if (!$3) { - if (FunctionManager::find(*$1, 0).ok()) { - $$ = new FunctionCallExpression($1); - } else { - throw nebula::GraphParser::syntax_error(@1, "Unknown function "); - } - } else if ($3->numArgs() == 1 && AggFunctionManager::find(*$1).ok()) { + if ($3->numArgs() == 1 && AggFunctionManager::find(*$1).ok()) { $$ = new AggregateExpression($1, $3->args()[0].release(), false); delete($3); } else if (FunctionManager::find(*$1, $3->numArgs()).ok()) { @@ -945,7 +939,7 @@ uuid_expression opt_argument_list : %empty { - $$ = nullptr; + $$ = new ArgumentList(); } | argument_list { $$ = $1; diff --git a/tests/tck/features/expression/FunctionCall.feature b/tests/tck/features/expression/FunctionCall.feature index 8b601691..b053830c 100644 --- a/tests/tck/features/expression/FunctionCall.feature +++ b/tests/tck/features/expression/FunctionCall.feature @@ -16,3 +16,13 @@ Feature: Function Call Expression Then the result should be, in any order: | a | b | c | d | e | f | | 1 | -1 | 1 | -1 | 0 | 1 | + + Scenario: date related + When executing query: + """ + YIELD timestamp("2000-10-10T10:00:00") AS a, date() AS b, time() AS c, + datetime() AS d + """ + Then the result should be, in any order: + | a | b | c | d | + | /^\d+$/ | /^\d{4}\-\d{2}-\d{2}$/ | /^\d{2}:\d{2}:\d{2}\.\d{6}$/ | /^\d{4}\-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{6}$/ | -- GitLab