Skip to content

Commit

Permalink
Merge branch 'master' into fix-session-update-time
Browse files Browse the repository at this point in the history
  • Loading branch information
Aiee authored Dec 28, 2022
2 parents 41531d7 + a0cfb0b commit fd52b56
Showing 1 changed file with 152 additions and 41 deletions.
193 changes: 152 additions & 41 deletions tests/tck/features/yield/parameter.feature
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,48 @@ 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
"""
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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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)
Expand All @@ -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
Expand All @@ -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;
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -210,12 +267,66 @@ 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
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'
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
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;
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
| 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 |

0 comments on commit fd52b56

Please sign in to comment.