From f48564470b6b397eb0149c4c33e66160d32d8d8d Mon Sep 17 00:00:00 2001 From: caton-hpg <87342612+caton-hpg@users.noreply.github.com> Date: Tue, 20 Dec 2022 15:48:52 +0800 Subject: [PATCH 1/5] parameter tck --- tests/tck/features/yield/parameter.feature | 142 +++++++++++++++------ 1 file changed, 103 insertions(+), 39 deletions(-) diff --git a/tests/tck/features/yield/parameter.feature b/tests/tck/features/yield/parameter.feature index 717c11cd9cf..66ec6434f19 100644 --- a/tests/tck/features/yield/parameter.feature +++ b/tests/tck/features/yield/parameter.feature @@ -7,7 +7,30 @@ Feature: Parameter Given a graph with space named "nba" Given parameters: {"p1":1,"p2":true,"p3":"Tim Duncan","p4":3.3,"p5":[1,true,3],"p6":{"a":3,"b":false,"c":"Tim Duncan"},"p7":{"a":{"b":{"c":"Tim Duncan","d":[1,2,3,true,"Tim Duncan"]}}},"p8":"Manu Ginobili", "p9":["Tim Duncan","Tony Parker"]} - Scenario: return parameters + Scenario: [param-test-001] without define param + When executing query: + """ + RETURN $p_not_exist AS v + """ + Then a SyntaxError should be raised at runtime: Direct output of variable is prohibited near `$p_not_exist' + + Scenario: [param-test-002] support null + When executing query: + """ + RETURN $p1 is not null AS v + """ + Then the result should be, in any order: + | v | + | true | + When executing query: + """ + RETURN $p1 is null AS v + """ + Then the result should be, in any order: + | v | + | false | + + Scenario: [param-test-003] return parameters When executing query: """ RETURN abs($p1)+1 AS ival, $p2 and false AS bval, $p3+"ef" AS sval, round($p4)+1.1 AS fval, $p5 AS lval, $p6.a AS mval, all(item in $p7.a.b.d where item<4 or ((item>0) is null)) AS pval @@ -15,8 +38,17 @@ Feature: Parameter Then the result should be, in any order: | ival | bval | sval | fval | lval | mval | pval | | 2 | false | "Tim Duncanef" | 4.1 | [1,true,3] | 3 | true | + # return map + When executing query: + """ + RETURN $p6 AS v + """ + Then the result should be, in any order: + | v | + | {a: 3, b: false, c: "Tim Duncan"} | - Scenario: cypher with parameters + Scenario: [param-test-004]cypher with parameters + # where clause When executing query: """ MATCH (v) WHERE id(v)==$p3 @@ -50,6 +82,24 @@ Feature: Parameter Then the result should be, in any order: | v | | "Tim Duncan" | + When profiling query: + """ + MATCH (v) WHERE id(v) IN $p9 + RETURN v.player.name AS v + """ + Then the result should be, in any order: + | v | + | "Tim Duncan" | + | "Tony Parker" | + And the execution plan should be: + | id | name | dependencies | operator info | + | 9 | Project | 7 | | + | 7 | Filter | 2 | | + | 2 | AppendVertices | 6 | | + | 6 | Dedup | 6 | | + | 6 | PassThrough | 0 | | + | 0 | Start | | | + # LIMIT When executing query: """ MATCH (v:player)-[:like]->(n) WHERE id(v)==$p3 and n.player.age>$p1+29 @@ -67,6 +117,7 @@ Feature: Parameter Then the result should be, in any order: | dst | | "Tim Duncan" | + # WITH clause When executing query: """ UNWIND $p5 AS c @@ -87,6 +138,7 @@ Feature: Parameter Then the result should be, in any order: | ival | bval | sval | fval | | 2 | false | "Tim Duncanef" | 4.1 | + # order by When executing query: """ MATCH (v:player) @@ -96,25 +148,8 @@ Feature: Parameter Then the result should be, in order: | v | | "Tim Duncan" | - When profiling query: - """ - MATCH (v) WHERE id(v) IN $p9 - RETURN v.player.name AS v - """ - Then the result should be, in any order: - | v | - | "Tim Duncan" | - | "Tony Parker" | - And the execution plan should be: - | id | name | dependencies | operator info | - | 9 | Project | 7 | | - | 7 | Filter | 2 | | - | 2 | AppendVertices | 6 | | - | 6 | Dedup | 6 | | - | 6 | PassThrough | 0 | | - | 0 | Start | | | - Scenario: ngql with parameters + Scenario: [param-test-005] lookup with parameters When executing query: """ LOOKUP ON player where player.age>$p1+40 YIELD player.name AS name @@ -128,12 +163,38 @@ Feature: Parameter | "Shaquille O'Neal" | | "Steve Nash" | | "Ray Allen" | + + Scenario: [param-test-006] go with parameters + # yield clause When executing query: """ - $p1=GO FROM "Tim Duncan" OVER like WHERE like.likeness>$p1 yield like._dst as dst; - GO FROM $p1.dst OVER like YIELD DISTINCT $$.player.name AS name + GO FROM "Tim Duncan" OVER like yield like._dst as dst, $p3; """ - Then a SyntaxError should be raised at runtime: Variable definition conflicts with a parameter near `$p1' + Then the result should be, in order: + | dst | $p3 | + | "Manu Ginobili" | "Tim Duncan" | + | "Tony Parker" | "Tim Duncan" | + # where clause + When executing query: + """ + GO FROM "Tim Duncan" OVER like WHERE like.likeness>$p1 yield like._dst as dst; + """ + Then the result should be, in order: + | dst | + | "Manu Ginobili" | + | "Tony Parker" | + # step cannot support + When executing query: + """ + GO $1 STEPS FROM "Tim Duncan" OVER like yield like._dst as dst; + """ + Then a SyntaxError should be raised at runtime: syntax error near `$1 STEPS' + # from cannot support + When executing query: + """ + GO FROM $p3 OVER like yield like._dst as dst; + """ + Then a SyntaxError should be raised at runtime: Parameter is not supported in vid near `$p3' When executing query: """ $var=GO FROM $p4 OVER like WHERE like.likeness>$p1 yield like._dst as dst; @@ -145,6 +206,13 @@ Feature: Parameter GO FROM $p3,$p4 OVER like """ Then a SyntaxError should be raised at runtime: Parameter is not supported in vid near `$p3' + When executing query: + """ + GO 1 TO 2 STEPS FROM "Tim Duncan" OVER like YIELD like._dst AS dst SAMPLE [1,$p1] + """ + Then a SyntaxError should be raised at runtime: Parameter is not supported in sample clause near `[1,$p1]' + + Scenario: [param-test-007] fetch with parameters When executing query: """ FETCH PROP ON player $nonexist @@ -155,6 +223,8 @@ Feature: Parameter FETCH PROP ON player $p3,$p4 """ Then a SyntaxError should be raised at runtime: Parameter is not supported in vid near `$p3' + + Scenario: [param-test-008] find-path with parameters When executing query: """ find noloop path from $p3 to $p2 over like @@ -170,28 +240,15 @@ Feature: Parameter find shortest path from $p3 to $p2 over like """ Then a SyntaxError should be raised at runtime: Parameter is not supported in vid near `$p3' + + Scenario: [param-test-009] get-subgraph with parameters When executing query: """ GET SUBGRAPH FROM $p3 BOTH like """ Then a SyntaxError should be raised at runtime: Parameter is not supported in vid near `$p3' - When executing query: - """ - find shortest path from $p3 to $p2 over like - """ - Then a SyntaxError should be raised at runtime: Parameter is not supported in vid near `$p3' - When executing query: - """ - find shortest path from $p3 to $p2 over like - """ - Then a SyntaxError should be raised at runtime: Parameter is not supported in vid near `$p3' - When executing query: - """ - GO 1 TO 2 STEPS FROM "Tim Duncan" OVER like YIELD like._dst AS dst SAMPLE [1,$p1] - """ - Then a SyntaxError should be raised at runtime: Parameter is not supported in sample clause near `[1,$p1]' - Scenario: error check + Scenario: [param-test-010] error type When executing query: """ LOOKUP ON player WHERE player.age>$p2+43 @@ -219,3 +276,10 @@ Feature: Parameter Then the result should be, in any order: | v | | 96.0 | + Scenario: [param-test-011] conflict name + When executing query: + """ + $p1=GO FROM "Tim Duncan" OVER like WHERE like.likeness>$p1 yield like._dst as dst; + GO FROM $p1.dst OVER like YIELD DISTINCT $$.player.name AS name + """ + Then a SyntaxError should be raised at runtime: Variable definition conflicts with a parameter near `$p1' From 36a7b01ce4e960e5d787dcf71b5b394b40bf2202 Mon Sep 17 00:00:00 2001 From: caton-hpg <87342612+caton-hpg@users.noreply.github.com> Date: Thu, 22 Dec 2022 10:08:29 +0800 Subject: [PATCH 2/5] format --- tests/tck/features/yield/parameter.feature | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/tck/features/yield/parameter.feature b/tests/tck/features/yield/parameter.feature index 66ec6434f19..2f5cba36280 100644 --- a/tests/tck/features/yield/parameter.feature +++ b/tests/tck/features/yield/parameter.feature @@ -48,7 +48,7 @@ Feature: Parameter | {a: 3, b: false, c: "Tim Duncan"} | Scenario: [param-test-004]cypher with parameters - # where clause + # where clause When executing query: """ MATCH (v) WHERE id(v)==$p3 @@ -163,7 +163,7 @@ Feature: Parameter | "Shaquille O'Neal" | | "Steve Nash" | | "Ray Allen" | - + Scenario: [param-test-006] go with parameters # yield clause When executing query: From 600f452e7489ba7c6c05bf4916a167aacbae0cc9 Mon Sep 17 00:00:00 2001 From: caton-hpg <87342612+caton-hpg@users.noreply.github.com> Date: Mon, 26 Dec 2022 14:05:00 +0800 Subject: [PATCH 3/5] add some tck --- tests/tck/features/yield/parameter.feature | 61 +++++++++++++++++++++- 1 file changed, 60 insertions(+), 1 deletion(-) diff --git a/tests/tck/features/yield/parameter.feature b/tests/tck/features/yield/parameter.feature index 2f5cba36280..229860bbbb4 100644 --- a/tests/tck/features/yield/parameter.feature +++ b/tests/tck/features/yield/parameter.feature @@ -47,7 +47,7 @@ Feature: Parameter | v | | {a: 3, b: false, c: "Tim Duncan"} | - Scenario: [param-test-004]cypher with parameters + Scenario: [param-test-004] cypher with parameters # where clause When executing query: """ @@ -283,3 +283,62 @@ Feature: Parameter GO FROM $p1.dst OVER like YIELD DISTINCT $$.player.name AS name """ Then a SyntaxError should be raised at runtime: Variable definition conflicts with a parameter near `$p1' + + Scenario: [param-test-012] expression with parameters + When executing query: + """ + go from "Tim Duncan" over like yield like._dst as id + | yield $-.id+$p1+hash(abs($p1)+$-.id) as v + """ + Then the result should be, in any order: + | v | + | "Manu Ginobili1-8422829895182987733" | + | "Tony Parker1803925327675532371" | + When executing query: + """ + $var=go from "Tim Duncan" over like yield like._dst as id; + yield $var.id+$p1+hash(abs($p1)+$var.id) as v + """ + Then the result should be, in any order: + | v | + | "Manu Ginobili1-8422829895182987733" | + | "Tony Parker1803925327675532371" | + # aggregate expressions + ## crash and fixed later + #When executing query: + # """ + # $var=go from "Tim Duncan" over like yield like._dst as id, like.likeness as likeness; + # yield avg($var.likeness)+$p1 as v; + # """ + #Then the result should be, in any order: + # | v | + # | 2 | + When executing query: + """ + go from "Tim Duncan" over like yield like._dst as id + | yield count(distinct abs($p1)+$-.id) as v + """ + Then the result should be, in any order: + | v | + | 2 | + # expression nesting + When executing query: + """ + go from "Tim Duncan" over like yield properties($$).age as age + | yield avg(abs(hash($-.age+$p1)+$p1)) as v + """ + Then the result should be, in any order: + | v | + | 40.5 | + # BAD_TYPE + When executing query: + """ + go from "Tim Duncan" over like yield properties($$).age as age + | yield abs($-.age+$p3) as v + """ + Then the result should be, in any order: + | v | + | BAD_TYPE | + | BAD_TYPE | + + From efe3ea97d1dda82cc0119e6eb86d54509b6c6f27 Mon Sep 17 00:00:00 2001 From: caton-hpg <87342612+caton-hpg@users.noreply.github.com> Date: Mon, 26 Dec 2022 14:34:27 +0800 Subject: [PATCH 4/5] format --- tests/tck/features/yield/parameter.feature | 24 ++++++++++------------ 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/tests/tck/features/yield/parameter.feature b/tests/tck/features/yield/parameter.feature index 229860bbbb4..4245d735171 100644 --- a/tests/tck/features/yield/parameter.feature +++ b/tests/tck/features/yield/parameter.feature @@ -304,15 +304,15 @@ Feature: Parameter | "Manu Ginobili1-8422829895182987733" | | "Tony Parker1803925327675532371" | # aggregate expressions - ## crash and fixed later - #When executing query: - # """ - # $var=go from "Tim Duncan" over like yield like._dst as id, like.likeness as likeness; - # yield avg($var.likeness)+$p1 as v; - # """ - #Then the result should be, in any order: - # | v | - # | 2 | + # crash and fixed later + # When executing query: + # """ + # $var=go from "Tim Duncan" over like yield like._dst as id, like.likeness as likeness; + # yield avg($var.likeness)+$p1 as v; + # """ + # Then the result should be, in any order: + # | v | + # | 2 | When executing query: """ go from "Tim Duncan" over like yield like._dst as id @@ -324,7 +324,7 @@ Feature: Parameter # expression nesting When executing query: """ - go from "Tim Duncan" over like yield properties($$).age as age + go from "Tim Duncan" over like yield properties($$).age as age | yield avg(abs(hash($-.age+$p1)+$p1)) as v """ Then the result should be, in any order: @@ -333,12 +333,10 @@ Feature: Parameter # BAD_TYPE When executing query: """ - go from "Tim Duncan" over like yield properties($$).age as age + go from "Tim Duncan" over like yield properties($$).age as age | yield abs($-.age+$p3) as v """ Then the result should be, in any order: | v | | BAD_TYPE | | BAD_TYPE | - - From 6077ac4af64cd2f5437fcfcfa9eaaaa0dddce8b2 Mon Sep 17 00:00:00 2001 From: caton-hpg <87342612+caton-hpg@users.noreply.github.com> Date: Tue, 27 Dec 2022 21:10:30 +0800 Subject: [PATCH 5/5] update tck --- tests/tck/features/yield/parameter.feature | 26 +++++++--------------- 1 file changed, 8 insertions(+), 18 deletions(-) diff --git a/tests/tck/features/yield/parameter.feature b/tests/tck/features/yield/parameter.feature index 4245d735171..83f44a85fa8 100644 --- a/tests/tck/features/yield/parameter.feature +++ b/tests/tck/features/yield/parameter.feature @@ -267,15 +267,6 @@ Feature: Parameter Then a SyntaxError should be raised at runtime: Direct output of variable is prohibited near `$var' Then clear the used parameters - Scenario: expression with parameters - When executing query: - """ - $var=go from "Tim Duncan" over like yield like._dst as id, like.likeness as likeness; - yield avg($var.likeness)+1 as v; - """ - Then the result should be, in any order: - | v | - | 96.0 | Scenario: [param-test-011] conflict name When executing query: """ @@ -304,15 +295,14 @@ Feature: Parameter | "Manu Ginobili1-8422829895182987733" | | "Tony Parker1803925327675532371" | # aggregate expressions - # crash and fixed later - # When executing query: - # """ - # $var=go from "Tim Duncan" over like yield like._dst as id, like.likeness as likeness; - # yield avg($var.likeness)+$p1 as v; - # """ - # Then the result should be, in any order: - # | v | - # | 2 | + When executing query: + """ + $var=go from "Tim Duncan" over like yield like._dst as id, like.likeness as likeness; + yield avg($var.likeness)+$p1 as v; + """ + Then the result should be, in any order: + | v | + | 96.0 | When executing query: """ go from "Tim Duncan" over like yield like._dst as id