From 831233e6a7f91a1523489433cd91c2de810b18b7 Mon Sep 17 00:00:00 2001 From: "jie.wang" <38901892+jievince@users.noreply.github.com> Date: Mon, 8 Feb 2021 15:52:30 +0800 Subject: [PATCH] Support sign function in parser (#740) * support function sign in parser * add test Co-authored-by: Yee <2520865+yixinglu@users.noreply.github.com> --- src/parser/parser.yy | 3 +++ .../features/expression/FunctionCall.feature | 18 ++++++++++++++++++ 2 files changed, 21 insertions(+) create mode 100644 tests/tck/features/expression/FunctionCall.feature diff --git a/src/parser/parser.yy b/src/parser/parser.yy index d68ff21d..2a9643d8 100644 --- a/src/parser/parser.yy +++ b/src/parser/parser.yy @@ -893,6 +893,9 @@ function_call_expression | KW_TAGS L_PAREN opt_argument_list R_PAREN { $$ = new FunctionCallExpression(new std::string("tags"), $3); } + | KW_SIGN L_PAREN opt_argument_list R_PAREN { + $$ = new FunctionCallExpression(new std::string("sign"), $3); + } ; aggregate_expression diff --git a/tests/tck/features/expression/FunctionCall.feature b/tests/tck/features/expression/FunctionCall.feature new file mode 100644 index 00000000..8b601691 --- /dev/null +++ b/tests/tck/features/expression/FunctionCall.feature @@ -0,0 +1,18 @@ +# Copyright (c) 2021 vesoft inc. All rights reserved. +# +# This source code is licensed under Apache 2.0 License, +# attached with Common Clause Condition 1.0, found in the LICENSES directory. +Feature: Function Call Expression + + Background: + Given a graph with space named "nba" + + Scenario: sign + When executing query: + """ + YIELD sign(38) AS a, sign(-2) AS b, sign(0.421) AS c, + sign(-1.0) AS d, sign(0) AS e, sign(abs(-3)) AS f + """ + Then the result should be, in any order: + | a | b | c | d | e | f | + | 1 | -1 | 1 | -1 | 0 | 1 | -- GitLab