From 8f5aca90ff0c6cbce27ed9197009ede20059f121 Mon Sep 17 00:00:00 2001 From: Shylock Hg <33566796+Shylock-Hg@users.noreply.github.com> Date: Fri, 13 Jan 2023 18:04:03 +0800 Subject: [PATCH 1/2] Add some tests about yield. --- tests/tck/features/yield/yield.feature | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tests/tck/features/yield/yield.feature b/tests/tck/features/yield/yield.feature index 47677b2cb3e..0b53cf86f6f 100644 --- a/tests/tck/features/yield/yield.feature +++ b/tests/tck/features/yield/yield.feature @@ -4,6 +4,13 @@ Feature: Yield Sentence Given a graph with space named "nba" Scenario: Base + When executing query: + """ + YIELD 1 + """ + Then the result should be, in any order + | 1 | + | 1 | When executing query: """ YIELD [1, 1.1, 1e2, 1.1e2, .3e4, 1.e4, 1234E-10, true] AS basic_value From e45c0f1fd85fdeac6204626a1f5c6de922a11f45 Mon Sep 17 00:00:00 2001 From: Shylock Hg <33566796+Shylock-Hg@users.noreply.github.com> Date: Tue, 17 Jan 2023 11:35:41 +0800 Subject: [PATCH 2/2] Add more tests. --- tests/tck/features/yield/yield.IntVid.feature | 149 ++++++++++++++++++ tests/tck/features/yield/yield.feature | 144 ++++++++++++++++- 2 files changed, 292 insertions(+), 1 deletion(-) diff --git a/tests/tck/features/yield/yield.IntVid.feature b/tests/tck/features/yield/yield.IntVid.feature index 0aef1b6b7e6..a6245d18a08 100644 --- a/tests/tck/features/yield/yield.IntVid.feature +++ b/tests/tck/features/yield/yield.IntVid.feature @@ -11,6 +11,141 @@ Feature: Yield Sentence Then the result should be, in any order: | 1 | | 1 | + When executing query: + """ + YIELD [1, 1.1, 1e2, 1.1e2, .3e4, 1.e4, 1234E-10, true] AS basic_value + """ + Then the result should be, in any order, with relax comparison: + | basic_value | + | [1, 1.1, 100.0, 110.0, 3000.0, 10000.0, 0.0000001234, true] | + When executing query: + """ + YIELD {p1: 1, p2: true, p3: "test"} AS r + """ + Then the result should be, in any order: + | r | + | {p1: 1, p2: true, p3: "test"} | + When executing query: + """ + YIELD true and false + """ + Then the result should be, in any order: + | (true AND false) | + | false | + When executing query: + """ + YIELD datetime('2012-03-04T22:11').year + """ + Then the result should be, in any order: + | datetime("2012-03-04T22:11").year | + | 2012 | + When executing query: + """ + YIELD datetime('2012-03-04T22:11').not_exists + """ + Then the result should be, in any order: + | datetime("2012-03-04T22:11").not_exists | + | UNKNOWN_PROP | + When executing query: + """ + YIELD CASE 1 WHEN 1 THEN 2 ELSE 3 END + """ + Then the result should be, in any order: + | CASE 1 WHEN 1 THEN 2 ELSE 3 END | + | 2 | + When executing query: + """ + YIELD abs(-1) + """ + Then the result should be, in any order: + | abs(-(1)) | + | 1 | + When executing query: + """ + YIELD v.l1.p1 + """ + Then a SemanticError should be raised at runtime: Invalid label identifiers: v + When executing query: + """ + YIELD l1 + """ + Then a SemanticError should be raised at runtime: Invalid label identifiers: l1 + When executing query: + """ + YIELD [i in [1, 2, 3] where i > 1 | i + 1] AS r + """ + Then the result should be, in any order: + | r | + | [3, 4] | + When executing query: + """ + YIELD all(n IN range(1, 5) WHERE n > 2) + """ + Then the result should be, in any order: + | all(n IN range(1,5) WHERE (n>2)) | + | false | + When executing query: + """ + YIELD like._dst + """ + Then a SemanticError should be raised at runtime: Only support input and variable in yield sentence. + When executing query: + """ + YIELD reduce(totalNum = 10, n IN range(1, 3) | totalNum + n) AS r + """ + Then the result should be, in any order: + | r | + | 16 | + When executing query: + """ + YIELD [1, 2, 3][2] + """ + Then the result should be, in any order: + | [1,2,3][2] | + | 3 | + When executing query: + """ + YIELD [1, 2, 3][0..1] + """ + Then the result should be, in any order: + | [1,2,3][0..1] | + | [1] | + When executing query: + """ + YIELD prefix(edge1.prop1,"高") + """ + Then a SyntaxError should be raised at runtime: syntax error near `(edge1.p' + When executing query: + """ + YIELD (INT)"1" + """ + Then the result should be, in any order: + | (INT)"1" | + | 1 | + When executing query: + """ + YIELD -(1) + """ + Then the result should be, in any order: + | -(1) | + | -1 | + When executing query: + """ + YIELD uuid() + """ + Then a SemanticError should be raised at runtime: Not supported expression `uuid()' for props deduction. + When executing query: + """ + YIELD $v + """ + Then a SyntaxError should be raised at runtime: Direct output of variable is prohibited near `$v' + When executing query: + """ + YIELD 1 AS num + """ + Then the result should be, in any order: + | num | + | 1 | When executing query: """ YIELD 1+1, (int)3.14, (string)(1+1), (string)true,"1+1" @@ -26,6 +161,20 @@ Feature: Yield Sentence | "Hello" | hash("Hello") | | "Hello" | 2275118702903107253 | + # TODO fix it + @skip + Scenario: Mistake + When executing query: + """ + YIELD count(*) + """ + Then a SemanticError should be raised at runtime: Don't support aggregate function without input. + When executing query: + """ + YIELD (v)-[:like]-() + """ + Then a SemanticError should be raised at runtime: Not support pattern expression. + Scenario: HashCall When executing query: """ diff --git a/tests/tck/features/yield/yield.feature b/tests/tck/features/yield/yield.feature index 0b53cf86f6f..db9ad24b36c 100644 --- a/tests/tck/features/yield/yield.feature +++ b/tests/tck/features/yield/yield.feature @@ -8,7 +8,7 @@ Feature: Yield Sentence """ YIELD 1 """ - Then the result should be, in any order + Then the result should be, in any order: | 1 | | 1 | When executing query: @@ -18,6 +18,134 @@ Feature: Yield Sentence Then the result should be, in any order, with relax comparison: | basic_value | | [1, 1.1, 100.0, 110.0, 3000.0, 10000.0, 0.0000001234, true] | + When executing query: + """ + YIELD {p1: 1, p2: true, p3: "test"} AS r + """ + Then the result should be, in any order: + | r | + | {p1: 1, p2: true, p3: "test"} | + When executing query: + """ + YIELD true and false + """ + Then the result should be, in any order: + | (true AND false) | + | false | + When executing query: + """ + YIELD datetime('2012-03-04T22:11').year + """ + Then the result should be, in any order: + | datetime("2012-03-04T22:11").year | + | 2012 | + When executing query: + """ + YIELD datetime('2012-03-04T22:11').not_exists + """ + Then the result should be, in any order: + | datetime("2012-03-04T22:11").not_exists | + | UNKNOWN_PROP | + When executing query: + """ + YIELD CASE 1 WHEN 1 THEN 2 ELSE 3 END + """ + Then the result should be, in any order: + | CASE 1 WHEN 1 THEN 2 ELSE 3 END | + | 2 | + When executing query: + """ + YIELD abs(-1) + """ + Then the result should be, in any order: + | abs(-(1)) | + | 1 | + When executing query: + """ + YIELD v.l1.p1 + """ + Then a SemanticError should be raised at runtime: Invalid label identifiers: v + When executing query: + """ + YIELD l1 + """ + Then a SemanticError should be raised at runtime: Invalid label identifiers: l1 + When executing query: + """ + YIELD [i in [1, 2, 3] where i > 1 | i + 1] AS r + """ + Then the result should be, in any order: + | r | + | [3, 4] | + When executing query: + """ + YIELD all(n IN range(1, 5) WHERE n > 2) + """ + Then the result should be, in any order: + | all(n IN range(1,5) WHERE (n>2)) | + | false | + When executing query: + """ + YIELD like._dst + """ + Then a SemanticError should be raised at runtime: Only support input and variable in yield sentence. + When executing query: + """ + YIELD reduce(totalNum = 10, n IN range(1, 3) | totalNum + n) AS r + """ + Then the result should be, in any order: + | r | + | 16 | + When executing query: + """ + YIELD [1, 2, 3][2] + """ + Then the result should be, in any order: + | [1,2,3][2] | + | 3 | + When executing query: + """ + YIELD [1, 2, 3][0..1] + """ + Then the result should be, in any order: + | [1,2,3][0..1] | + | [1] | + When executing query: + """ + YIELD prefix(edge1.prop1,"高") + """ + Then a SyntaxError should be raised at runtime: syntax error near `(edge1.p' + When executing query: + """ + YIELD (int)"1" + """ + Then the result should be, in any order: + | (INT)"1" | + | 1 | + When executing query: + """ + YIELD -(1) + """ + Then the result should be, in any order: + | -(1) | + | -1 | + When executing query: + """ + YIELD uuid() + """ + Then a SemanticError should be raised at runtime: Not supported expression `uuid()' for props deduction. + When executing query: + """ + YIELD $v + """ + Then a SyntaxError should be raised at runtime: Direct output of variable is prohibited near `$v' + When executing query: + """ + YIELD 1 AS num + """ + Then the result should be, in any order: + | num | + | 1 | When executing query: """ YIELD 1+1, (int)3.14, (string)(1+1), (string)true,"1+1" @@ -33,6 +161,20 @@ Feature: Yield Sentence | "Hello" | hash("Hello") | | "Hello" | 2275118702903107253 | + # TODO fix it + @skip + Scenario: Mistake + When executing query: + """ + YIELD count(*) + """ + Then a SemanticError should be raised at runtime: Don't support aggregate function without input. + When executing query: + """ + YIELD (v)-[:like]-() + """ + Then a SemanticError should be raised at runtime: Not support pattern expression. + Scenario: HashCall When executing query: """