Skip to content

Commit

Permalink
disable mixed used of cypher & ngql
Browse files Browse the repository at this point in the history
  • Loading branch information
nevermore3 committed Dec 20, 2021
1 parent af74bab commit 3d92ad6
Show file tree
Hide file tree
Showing 15 changed files with 67 additions and 85 deletions.
2 changes: 1 addition & 1 deletion src/parser/parser.yy
Original file line number Diff line number Diff line change
Expand Up @@ -2777,7 +2777,6 @@ desc_zone_sentence
traverse_sentence
: L_PAREN set_sentence R_PAREN { $$ = $2; }
| go_sentence { $$ = $1; }
| match_sentence { $$ = $1; }
| lookup_sentence { $$ = $1; }
| group_by_sentence { $$ = $1; }
| order_by_sentence { $$ = $1; }
Expand Down Expand Up @@ -3747,6 +3746,7 @@ sentence
| set_sentence { $$ = $1; }
| assignment_sentence { $$ = $1; }
| mutate_sentence { $$ = $1; }
| match_sentence { $$ = $1; }
;

seq_sentences
Expand Down
6 changes: 3 additions & 3 deletions tests/tck/features/aggregate/Agg.feature
Original file line number Diff line number Diff line change
Expand Up @@ -493,14 +493,14 @@ Feature: Basic Aggregate and GroupBy
| 0 | 0 | NULL | NULL | NULL | NULL | NULL | NULL | NULL |
When executing query:
"""
UNWIND [1,2,3] AS d RETURN d | YIELD 1 IN COLLECT($-.d) AS b
UNWIND [1,2,3] AS d RETURN 1 IN COLLECT(d) AS b
"""
Then the result should be, in order, with relax comparison:
| b |
| True |
When executing query:
"""
UNWIND [1,2,3] AS d RETURN d | YIELD ANY(l IN COLLECT($-.d) WHERE l==1) AS b
UNWIND [1,2,3] AS d RETURN ANY(l IN COLLECT(d) WHERE l==1) AS b
"""
Then the result should be, in order, with relax comparison:
| b |
Expand Down Expand Up @@ -607,7 +607,7 @@ Feature: Basic Aggregate and GroupBy
Scenario: Distinct sum
When executing query:
"""
UNWIND [1,2,3,3] AS d RETURN d | YIELD sum(distinct $-.d) AS sum
UNWIND [1,2,3,3] AS d RETURN sum(distinct d) AS sum
"""
Then the result should be, in any order:
| sum |
Expand Down
17 changes: 8 additions & 9 deletions tests/tck/features/bugfix/MatchUsedInPipe.feature
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Feature: Test match used in pipe
Scenario: Order by after match
When executing query:
"""
MATCH (n:player{name:"Tim Duncan"})-[]-(m) RETURN n,m | ORDER BY $-.m;
MATCH (n:player{name:"Tim Duncan"})-[]-(m) RETURN n,m ORDER BY m;
"""
Then the result should be, in any order, with relax comparison:
| n | m |
Expand All @@ -36,10 +36,12 @@ Feature: Test match used in pipe
Scenario: Group after match
When executing query:
"""
MATCH (n:player{name:"Tim Duncan"})-[]-(m) RETURN n,m | GROUP BY $-.n, $-.m YIELD $-.n, $-.m, count(*);
MATCH (n:player{name:"Tim Duncan"})-[]-(m)
WITH n as a, m as b
RETURN a, b, count(*)
"""
Then the result should be, in any order, with relax comparison:
| $-.n | $-.m | count(*) |
| a | b | count(*) |
| ("Tim Duncan") | ("Spurs") | 1 |
| ("Tim Duncan") | ("Shaquille O'Neal") | 1 |
| ("Tim Duncan") | ("Tiago Splitter") | 1 |
Expand All @@ -55,7 +57,7 @@ Feature: Test match used in pipe
Scenario: Top n after match
When executing query:
"""
MATCH (n:player{name:"Tim Duncan"})-[]-(m) RETURN n,m | ORDER BY $-.m | LIMIT 10;
MATCH (n:player{name:"Tim Duncan"})-[]-(m) RETURN n,m ORDER BY m LIMIT 10;
"""
Then the result should be, in any order, with relax comparison:
| n | m |
Expand All @@ -75,14 +77,11 @@ Feature: Test match used in pipe
"""
MATCH (n:player{name:"Tim Duncan"})-[]-(m) RETURN n,m | GO FROM $-.n OVER *;
"""
Then a SemanticError should be raised at runtime: `$-.n', the srcs should be type of FIXED_STRING, but was`__EMPTY__'
Then a SyntaxError should be raised at runtime: syntax error near `| GO FRO'

Scenario: Set op after match
When executing query:
"""
MATCH (n:player{name:"Tim Duncan"}) RETURN n UNION MATCH (n:player{name:"Tony Parker"}) RETURN n
"""
Then the result should be, in any order, with relax comparison:
| n |
| ("Tim Duncan") |
| ("Tony Parker") |
Then a SyntaxError should be raised at runtime: syntax error near `UNION'
4 changes: 2 additions & 2 deletions tests/tck/features/expression/ListComprehension.feature
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,8 @@ Feature: ListComprehension
Given a graph with space named "nba"
When executing query:
"""
UNWIND [1, 2, 3, 4, 5] AS a RETURN a * 2 AS x
| RETURN [n in collect($-.x) WHERE n > 5 | n + 1] AS l
UNWIND [1, 2, 3, 4, 5] AS a WITH a * 2 AS x
RETURN [n in collect($-.x) WHERE n > 5 | n + 1] AS l
"""
Then the result should be, in any order:
| l |
Expand Down
8 changes: 4 additions & 4 deletions tests/tck/features/expression/Predicate.feature
Original file line number Diff line number Diff line change
Expand Up @@ -232,28 +232,28 @@ Feature: Predicate
Given a graph with space named "nba"
When executing query:
"""
UNWIND [1, 2, 3, 4, 5] AS a RETURN a * 2 AS x | RETURN any(n in collect($-.x) WHERE n > 5) AS myboo
UNWIND [1, 2, 3, 4, 5] AS a WITH a * 2 AS x RETURN any(n in collect(x) WHERE n > 5) AS myboo
"""
Then the result should be, in any order:
| myboo |
| true |
When executing query:
"""
UNWIND [1, 2, 3, 4, 5] AS a RETURN a * 2 AS x | RETURN All(n in collect($-.x) WHERE n > 5) AS myboo
UNWIND [1, 2, 3, 4, 5] AS a WITH a * 2 AS x RETURN All(n in collect(x) WHERE n > 5) AS myboo
"""
Then the result should be, in any order:
| myboo |
| false |
When executing query:
"""
UNWIND [1, 2, 3, 4, 5] AS a RETURN a * 2 AS x | RETURN single(n in collect($-.x) WHERE n > 5) AS myboo
UNWIND [1, 2, 3, 4, 5] AS a WITH a * 2 AS x RETURN single(n in collect(x) WHERE n > 5) AS myboo
"""
Then the result should be, in any order:
| myboo |
| false |
When executing query:
"""
UNWIND [1, 2, 3, 4, 5] AS a RETURN a * 2 AS x | RETURN None(n in collect($-.x) WHERE n > 5) AS myboo
UNWIND [1, 2, 3, 4, 5] AS a WITH a * 2 AS x RETURN None(n in collect(x) WHERE n > 5) AS myboo
"""
Then the result should be, in any order:
| myboo |
Expand Down
4 changes: 2 additions & 2 deletions tests/tck/features/expression/Reduce.feature
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,8 @@ Feature: Reduce
Given a graph with space named "nba"
When executing query:
"""
UNWIND [1, 2, 3, 4, 5] AS a RETURN a * 2 AS x
| RETURN reduce(totalNum = 10, n in collect($-.x) | totalNum + n * 2) AS total
UNWIND [1, 2, 3, 4, 5] AS a WITH a * 2 AS x
RETURN reduce(totalNum = 10, n in collect(x) | totalNum + n * 2) AS total
"""
Then the result should be, in any order:
| total |
Expand Down
10 changes: 4 additions & 6 deletions tests/tck/features/match/MatchById.IntVid.feature
Original file line number Diff line number Diff line change
Expand Up @@ -904,15 +904,15 @@ Feature: Integer Vid Match By Id
When executing query:
"""
MATCH (:player{name: "Tim Duncan"})-[e:like*2..3]-(v)
RETURN 1 | YIELD COUNT(1)
RETURN COUNT(1)
"""
Then the result should be, in any order, with relax comparison:
| COUNT(1) |
| 292 |
When executing query:
"""
MATCH (:player{name:"Tim Duncan"})-[e:serve|like*2..3]-(v)
RETURN 1 | YIELD COUNT(1)
RETURN COUNT(1)
"""
Then the result should be, in any order, with relax comparison:
| COUNT(1) |
Expand All @@ -934,8 +934,7 @@ Feature: Integer Vid Match By Id
"""
MATCH (v1)-[:like]->(v2:player)-[:serve]->(v3)
WHERE id(v2) == hash('Tim Duncan')
RETURN v1, v3 |
YIELD COUNT(*)
RETURN COUNT(*)
"""
Then the result should be, in any order, with relax comparison:
| COUNT(*) |
Expand All @@ -944,8 +943,7 @@ Feature: Integer Vid Match By Id
"""
MATCH (v1)-[:like]->(v2:player)-[:serve]->(v3)
WHERE id(v3) == hash('Spurs')
RETURN v1 |
YIELD COUNT(*)
RETURN COUNT(*)
"""
Then the result should be, in any order, with relax comparison:
| COUNT(*) |
Expand Down
10 changes: 4 additions & 6 deletions tests/tck/features/match/MatchById.feature
Original file line number Diff line number Diff line change
Expand Up @@ -904,15 +904,15 @@ Feature: Match By Id
When executing query:
"""
MATCH (:player{name: "Tim Duncan"})-[e:like*2..3]-(v)
RETURN 1 | YIELD count(1)
RETURN count(1)
"""
Then the result should be, in any order, with relax comparison:
| count(1) |
| 292 |
When executing query:
"""
MATCH (:player{name:"Tim Duncan"})-[e:serve|like*2..3]-(v)
RETURN 1 | YIELD count(1)
RETURN count(1)
"""
Then the result should be, in any order, with relax comparison:
| count(1) |
Expand All @@ -934,8 +934,7 @@ Feature: Match By Id
"""
MATCH (v1)-[:like]->(v2:player)-[:serve]->(v3)
WHERE id(v2) == 'Tim Duncan'
RETURN v1, v3 |
YIELD COUNT(*)
RETURN COUNT(*)
"""
Then the result should be, in any order, with relax comparison:
| COUNT(*) |
Expand All @@ -944,8 +943,7 @@ Feature: Match By Id
"""
MATCH (v1)-[:like]->(v2:player)-[:serve]->(v3)
WHERE id(v3) == 'Spurs'
RETURN v1 |
YIELD COUNT(*)
RETURN COUNT(*)
"""
Then the result should be, in any order, with relax comparison:
| COUNT(*) |
Expand Down
8 changes: 4 additions & 4 deletions tests/tck/features/match/MatchGroupBy.feature
Original file line number Diff line number Diff line change
Expand Up @@ -137,15 +137,15 @@ Feature: Match GroupBy
"""
MATCH(n:player)-[:like*2]->(m)-[:serve]->()
WHERE n.age > 35
RETURN DISTINCT id(n) AS id,
WITH DISTINCT id(n) AS id,
count(n) AS count,
sum(floor(n.age)) AS sum,
max(m.age) AS max,
min(n.age) AS min,
avg(distinct n.age)+1 AS age,
labels(m) AS lb
ORDER BY id, count, max, min
| YIELD count(*) AS count;
RETURN count(*) AS count;
"""
Then the result should be, in order, with relax comparison:
| count |
Expand All @@ -156,15 +156,15 @@ Feature: Match GroupBy
"""
MATCH(n:player)-[:like*2]->(m)-[:serve]->()
WHERE n.age > 35
RETURN DISTINCT id(n) AS id,
WITH DISTINCT id(n) AS id,
count(n) AS count,
sum(floor(n.age)) AS sum,
max(m.age) AS max,
min(n.age) AS min,
avg(distinct n.age)+1 AS age,
labels(m) AS lb
ORDER BY id, count, max, min
| YIELD DISTINCT $-.min AS min, (INT)count(*) AS count;
RETURN DISTINCT min, (INT)count(*) AS count;
"""
Then the result should be, in any order, with relax comparison:
| min | count |
Expand Down
25 changes: 13 additions & 12 deletions tests/tck/features/match/PipeAndVariable.feature
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
# Copyright (c) 2021 vesoft inc. All rights reserved.
#
# This source code is licensed under Apache 2.0 License.
Feature: Pipe or use variable to store the match results
@skip
Feature: Pipe or use variable to store the lookup results

Background:
Given a graph with space named "nba"

Scenario: pipe match results
Scenario: pipe lookup results
When executing query:
"""
MATCH (v:player)
WHERE v.name CONTAINS 'Tim'
RETURN v.age AS age, id(v) AS vid |
LOOKUP ON player
WHERE player.name CONTAINS 'Tim'
YIELD player.age AS age, id(vertex) AS vid |
GO FROM $-.vid
OVER like REVERSELY
YIELD
Expand All @@ -33,12 +34,12 @@ Feature: Pipe or use variable to store the match results
| 42 | false | "Tim Duncan" | "Tiago Splitter" |
| 42 | true | "Tim Duncan" | "Tony Parker" |

Scenario: use variable to store match results
Scenario: use variable to store lookup results
When executing query:
"""
$var = MATCH (v:player)
WHERE v.name CONTAINS 'Tim'
RETURN v.age AS age, id(v) AS vid;
$var = LOOKUP ON player
WHERE player.name CONTAINS 'Tim'
YIELD player.age AS age, id(vertex) AS vid;
GO FROM $var.vid
OVER like REVERSELY
YIELD
Expand All @@ -63,9 +64,9 @@ Feature: Pipe or use variable to store the match results
Scenario: yield collect
When executing query:
"""
MATCH (v:player)
WHERE v.name CONTAINS 'Tim'
RETURN v.age as age, id(v) as vid |
LOOKUP ON player
WHERE player.name CONTAINS 'Tim'
YIELD player.age as age, id(vertex) as vid |
GO FROM $-.vid OVER like REVERSELY YIELD $-.age AS age, like._dst AS dst |
YIELD
any(d IN COLLECT(DISTINCT $-.dst) WHERE d=='Tony Parker') AS d,
Expand Down
19 changes: 7 additions & 12 deletions tests/tck/features/match/StartFromAnyNode.IntVid.feature
Original file line number Diff line number Diff line change
Expand Up @@ -181,8 +181,7 @@ Feature: Start From Any Node
When executing query:
"""
MATCH p = (n)-[]-(m:player{name:"Kyle Anderson"})-[]-(l)-[]-(k)
RETURN p
| YIELD count(*) AS count
RETURN count(p) AS count
"""
Then the result should be, in any order, with relax comparison:
| count |
Expand Down Expand Up @@ -223,8 +222,7 @@ Feature: Start From Any Node
When executing query:
"""
MATCH p = (k)-[]-(n)-[]-(m:player{name:"Kobe Bryant"})-[]-(l)
RETURN p
| YIELD count(*) AS count
RETURN count(p) AS count
"""
Then the result should be, in any order, with relax comparison:
| count |
Expand Down Expand Up @@ -306,8 +304,7 @@ Feature: Start From Any Node
When executing query:
"""
MATCH p = ()-[]-(n)-[]-(m:player{name:"Kobe Bryant"})-[]-(l)-[]-(k)
RETURN p
| YIELD count(*) AS count
RETURN count(p) AS count
"""
Then the result should be, in any order, with relax comparison:
| count |
Expand Down Expand Up @@ -481,8 +478,7 @@ Feature: Start From Any Node
When executing query:
"""
MATCH (n)-[]-(m:player{name:"Kyle Anderson"})-[*1..2]-(l)
RETURN n,m,l
| YIELD count(*) AS count
RETURN count(*) AS count
"""
Then the result should be, in any order, with relax comparison:
| count |
Expand All @@ -492,17 +488,16 @@ Feature: Start From Any Node
When executing query:
"""
MATCH (n)-[*1..2]-(m:player{name:"Kyle Anderson"})-[*1..2]-(l)
RETURN n,m,l
| YIELD count(*) AS count
WITH n as a, m as b, l as c
RETURN count(*) AS count
"""
Then the result should be, in any order, with relax comparison:
| count |
| 1846 |
When executing query:
"""
MATCH p = (n)-[*1..2]-(m:player{name:"Kyle Anderson"})-[]-(l)-[]-(k)
RETURN p
| YIELD count(*) AS count
RETURN count(p) AS count
"""
Then the result should be, in any order, with relax comparison:
| count |
Expand Down
Loading

0 comments on commit 3d92ad6

Please sign in to comment.