Skip to content

Commit

Permalink
fix test error
Browse files Browse the repository at this point in the history
  • Loading branch information
nevermore3 committed Jul 24, 2022
1 parent 786b2e9 commit 82118e8
Show file tree
Hide file tree
Showing 5 changed files with 100 additions and 52 deletions.
1 change: 0 additions & 1 deletion src/graph/optimizer/rule/RemoveNoopProjectRule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ namespace opt {
// PlanNode::Kind::kIntersect, intersect has no value in result
// PlanNode::Kind::kMinus, minus has no value in result
PlanNode::Kind::kProject,
PlanNode::Kind::kUnwind,
PlanNode::Kind::kSort,
PlanNode::Kind::kTopN,
// PlanNode::Kind::kLimit, limit has no value in result
Expand Down
11 changes: 9 additions & 2 deletions src/graph/validator/UnwindValidator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,15 @@ Status UnwindValidator::validateImpl() {
}
alias_ = unwindSentence->alias();
unwindExpr_ = unwindSentence->expr()->clone();
if (ExpressionUtils::hasAny(unwindExpr_, {Expression::Kind::kAggregate})) {
return Status::SemanticError("Can't use aggregating expressions in unwind clause, `%s'",

if (ExpressionUtils::findAny(unwindExpr_,
{Expression::Kind::kSrcProperty,
Expression::Kind::kDstProperty,
Expression::Kind::kVarProperty,
Expression::Kind::kLabel,
Expression::Kind::kAggregate,
Expression::Kind::kEdgeProperty})) {
return Status::SemanticError("Not support `%s' in UNWIND sentence.",
unwindExpr_->toString().c_str());
}

Expand Down
2 changes: 1 addition & 1 deletion src/parser/parser.yy
Original file line number Diff line number Diff line change
Expand Up @@ -2942,11 +2942,11 @@ traverse_sentence
| show_queries_sentence { $$ = $1; }
| kill_query_sentence { $$ = $1; }
| describe_user_sentence { $$ = $1; }
| unwind_sentence { $$ = $1; }
;

piped_sentence
: traverse_sentence { $$ = $1; }
| piped_sentence PIPE unwind_sentence { $$ = new PipedSentence($1, $3); }
| piped_sentence PIPE traverse_sentence { $$ = new PipedSentence($1, $3); }
| piped_sentence PIPE limit_sentence { $$ = new PipedSentence($1, $3); }
;
Expand Down
98 changes: 90 additions & 8 deletions tests/tck/features/match/PipeAndVariable.feature
Original file line number Diff line number Diff line change
Expand Up @@ -79,26 +79,108 @@ Feature: Pipe or use variable to store the lookup results
| true | 42 |

Scenario: mixed usage of cypher and ngql
When executing query:
"""
YIELD ['Tim Duncan', 'Tony Parker'] AS a
| UNWIND $-.a AS b
| GO FROM $-.b OVER like YIELD edge AS e
"""
Then the result should be, in any order:
| e |
| [:like "Tim Duncan"->"Manu Ginobili" @0 {likeness: 95}] |
| [:like "Tim Duncan"->"Tony Parker" @0 {likeness: 95}] |
| [:like "Tony Parker"->"LaMarcus Aldridge" @0 {likeness: 90}] |
| [:like "Tony Parker"->"Manu Ginobili" @0 {likeness: 95}] |
| [:like "Tony Parker"->"Tim Duncan" @0 {likeness: 95}] |
When executing query:
"""
YIELD {a:1, b:['Tim Duncan', 'Tony Parker'], c:'Tim Duncan'} AS a
| YIELD $-.a.b AS b
| UNWIND $-.b AS c
| GO FROM $-.c OVER like YIELD edge AS e
"""
Then the result should be, in any order:
| e |
| [:like "Tim Duncan"->"Manu Ginobili" @0 {likeness: 95}] |
| [:like "Tim Duncan"->"Tony Parker" @0 {likeness: 95}] |
| [:like "Tony Parker"->"LaMarcus Aldridge" @0 {likeness: 90}] |
| [:like "Tony Parker"->"Manu Ginobili" @0 {likeness: 95}] |
| [:like "Tony Parker"->"Tim Duncan" @0 {likeness: 95}] |
When executing query:
"""
YIELD {a:1, b:['Tim Duncan', 'Tony Parker'], c:'Tim Duncan'} AS a
| YIELD $-.a.c AS b
| UNWIND $-.b AS c
| GO FROM $-.c OVER like YIELD edge AS e
"""
Then the result should be, in any order:
| e |
| [:like "Tim Duncan"->"Manu Ginobili" @0 {likeness: 95}] |
| [:like "Tim Duncan"->"Tony Parker" @0 {likeness: 95}] |
When executing query:
"""
LOOKUP ON player
WHERE player.name == 'Tim Duncan'
YIELD player.age as age, id(vertex) as vid
| UNWIND $-.vid as a RETURN a
| UNWIND $-.vid as a | YIELD $-.a AS id
"""
Then a SyntaxError should be raised at runtime: syntax error near `UNWIND'
Then the result should be, in any order, with relax comparison:
| id |
| "Tim Duncan" |
When executing query:
"""
GET SUBGRAPH 2 STEPS FROM "Tim Duncan" BOTH like YIELD edges as e
| UNWIND $-.e as a RETURN a
"""
Then a SyntaxError should be raised at runtime: syntax error near `UNWIND'
| UNWIND $-.e as a | YIELD $-.a AS a
"""
Then the result should be, in any order, with relax comparison:
| a |
| [:like "Aron Baynes"->"Tim Duncan" @0 {}] |
| [:like "Boris Diaw"->"Tim Duncan" @0 {}] |
| [:like "Danny Green"->"Tim Duncan" @0 {}] |
| [:like "Dejounte Murray"->"Tim Duncan" @0 {}] |
| [:like "LaMarcus Aldridge"->"Tim Duncan" @0 {}] |
| [:like "Manu Ginobili"->"Tim Duncan" @0 {}] |
| [:like "Marco Belinelli"->"Tim Duncan" @0 {}] |
| [:like "Shaquille O'Neal"->"Tim Duncan" @0 {}] |
| [:like "Tiago Splitter"->"Tim Duncan" @0 {}] |
| [:like "Tony Parker"->"Tim Duncan" @0 {}] |
| [:like "Tim Duncan"->"Manu Ginobili" @0 {}] |
| [:like "Tim Duncan"->"Tony Parker" @0 {}] |
| [:like "Damian Lillard"->"LaMarcus Aldridge" @0 {}] |
| [:like "Rudy Gay"->"LaMarcus Aldridge" @0 {}] |
| [:like "LaMarcus Aldridge"->"Tony Parker" @0 {}] |
| [:like "Boris Diaw"->"Tony Parker" @0 {}] |
| [:like "Dejounte Murray"->"Chris Paul" @0 {}] |
| [:like "Dejounte Murray"->"Danny Green" @0 {}] |
| [:like "Dejounte Murray"->"James Harden" @0 {}] |
| [:like "Dejounte Murray"->"Kevin Durant" @0 {}] |
| [:like "Dejounte Murray"->"Kyle Anderson" @0 {}] |
| [:like "Dejounte Murray"->"LeBron James" @0 {}] |
| [:like "Dejounte Murray"->"Manu Ginobili" @0 {}] |
| [:like "Dejounte Murray"->"Marco Belinelli" @0 {}] |
| [:like "Dejounte Murray"->"Russell Westbrook" @0 {}] |
| [:like "Dejounte Murray"->"Tony Parker" @0 {}] |
| [:like "Danny Green"->"LeBron James" @0 {}] |
| [:like "Danny Green"->"Marco Belinelli" @0 {}] |
| [:like "Marco Belinelli"->"Danny Green" @0 {}] |
| [:like "Marco Belinelli"->"Tony Parker" @0 {}] |
| [:like "Yao Ming"->"Shaquille O'Neal" @0 {}] |
| [:like "Shaquille O'Neal"->"JaVale McGee" @0 {}] |
| [:like "Tiago Splitter"->"Manu Ginobili" @0 {}] |
| [:like "Tony Parker"->"LaMarcus Aldridge" @0 {}] |
| [:like "Tony Parker"->"Manu Ginobili" @0 {}] |
| [:like "James Harden"->"Russell Westbrook" @0 {}] |
| [:like "Chris Paul"->"LeBron James" @0 {}] |
| [:like "Russell Westbrook"->"James Harden" @0 {}] |
When executing query:
"""
FIND SHORTEST PATH FROM "Tim Duncan" TO "Yao Ming" OVER like YIELD path as p
| UNWIND $-.p as a RETURN a
FIND SHORTEST PATH FROM "Tim Duncan" TO "Tony Parker" OVER like YIELD path as p
| YIELD nodes($-.p) AS nodes | UNWIND $-.nodes AS a | YIELD $-.a AS a
"""
Then a SyntaxError should be raised at runtime: syntax error near `UNWIND'
Then the result should be, in any order, with relax comparison:
| a |
| ("Tim Duncan") |
| ("Tony Parker") |
When executing query:
"""
GO 2 STEPS FROM "Tim Duncan" OVER * YIELD dst(edge) as id
Expand Down
40 changes: 0 additions & 40 deletions tests/tck/features/match/Unwind.feature
Original file line number Diff line number Diff line change
Expand Up @@ -116,46 +116,6 @@ Feature: Unwind clause
| min | max |
| false | true |

Scenario: unwind pipe ngql
When executing query:
"""
YIELD ['Tim Duncan', 'Tony Parker'] AS a
| UNWIND $-.a AS b
| GO FROM $-.b OVER like YIELD edge AS e
"""
Then the result should be, in any order:
| e |
| [:like "Tim Duncan"->"Manu Ginobili" @0 {likeness: 95}] |
| [:like "Tim Duncan"->"Tony Parker" @0 {likeness: 95}] |
| [:like "Tony Parker"->"LaMarcus Aldridge" @0 {likeness: 90}] |
| [:like "Tony Parker"->"Manu Ginobili" @0 {likeness: 95}] |
| [:like "Tony Parker"->"Tim Duncan" @0 {likeness: 95}] |
When executing query:
"""
YIELD {a:1, b:['Tim Duncan', 'Tony Parker'], c:'Tim Duncan'} AS a
| YIELD $-.a.b AS b
| UNWIND $-.b AS c
| GO FROM $-.c OVER like YIELD edge AS e
"""
Then the result should be, in any order:
| e |
| [:like "Tim Duncan"->"Manu Ginobili" @0 {likeness: 95}] |
| [:like "Tim Duncan"->"Tony Parker" @0 {likeness: 95}] |
| [:like "Tony Parker"->"LaMarcus Aldridge" @0 {likeness: 90}] |
| [:like "Tony Parker"->"Manu Ginobili" @0 {likeness: 95}] |
| [:like "Tony Parker"->"Tim Duncan" @0 {likeness: 95}] |
When executing query:
"""
YIELD {a:1, b:['Tim Duncan', 'Tony Parker'], c:'Tim Duncan'} AS a
| YIELD $-.a.c AS b
| UNWIND $-.b AS c
| GO FROM $-.c OVER like YIELD edge AS e
"""
Then the result should be, in any order:
| e |
| [:like "Tim Duncan"->"Manu Ginobili" @0 {likeness: 95}] |
| [:like "Tim Duncan"->"Tony Parker" @0 {likeness: 95}] |

Scenario: unwind match with
When executing query:
"""
Expand Down

0 comments on commit 82118e8

Please sign in to comment.