From fa45f497e91f14e16a1aafe18411e9464d3d2279 Mon Sep 17 00:00:00 2001 From: jimingquan Date: Sat, 23 Jul 2022 23:07:33 +0800 Subject: [PATCH] add test case --- src/graph/executor/query/UnwindExecutor.cpp | 4 +-- tests/tck/features/match/Unwind.feature | 40 +++++++++++++++++++++ 2 files changed, 42 insertions(+), 2 deletions(-) diff --git a/src/graph/executor/query/UnwindExecutor.cpp b/src/graph/executor/query/UnwindExecutor.cpp index 1e42993fa3b..0dfa4e4b450 100644 --- a/src/graph/executor/query/UnwindExecutor.cpp +++ b/src/graph/executor/query/UnwindExecutor.cpp @@ -15,7 +15,7 @@ folly::Future UnwindExecutor::execute() { auto *unwind = asNode(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(); @@ -26,7 +26,7 @@ folly::Future UnwindExecutor::execute() { std::vector 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)); diff --git a/tests/tck/features/match/Unwind.feature b/tests/tck/features/match/Unwind.feature index 8d9b865ce46..4662fd50dca 100644 --- a/tests/tck/features/match/Unwind.feature +++ b/tests/tck/features/match/Unwind.feature @@ -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: """