Skip to content

Commit

Permalink
add test case
Browse files Browse the repository at this point in the history
  • Loading branch information
nevermore3 committed Jul 23, 2022
1 parent 796131c commit fa45f49
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/graph/executor/query/UnwindExecutor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ folly::Future<Status> UnwindExecutor::execute() {
auto *unwind = asNode<Unwind>(node());
auto &inputRes = ectx_->getResult(unwind->inputVar());
auto iter = inputRes.iter();
bool emptyInput = inputRes.valuePtr()->type() == Value::Type::DATASET ? false : true;
bool emptyInput = inputRes.valuePtr()->type() == Value::Type::DATASET || unwind->fromPipe();
QueryExpressionContext ctx(ectx_);
auto *unwindExpr = unwind->unwindExpr();

Expand All @@ -26,7 +26,7 @@ folly::Future<Status> UnwindExecutor::execute() {
std::vector<Value> vals = extractList(list);
for (auto &v : vals) {
Row row;
if (!unwind->fromPipe() && !emptyInput) {
if (!emptyInput) {
row = *(iter->row());
}
row.values.emplace_back(std::move(v));
Expand Down
40 changes: 40 additions & 0 deletions tests/tck/features/match/Unwind.feature
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,46 @@ 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 fa45f49

Please sign in to comment.