From c1ae2ef654e260169b94aed32b510eac1b22e693 Mon Sep 17 00:00:00 2001 From: jievince <38901892+jievince@users.noreply.github.com> Date: Mon, 17 Oct 2022 15:40:49 +0800 Subject: [PATCH] fix dep of loop in go planner --- src/graph/planner/ngql/GoPlanner.cpp | 2 +- tests/tck/features/go/SimpleCase.feature | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/src/graph/planner/ngql/GoPlanner.cpp b/src/graph/planner/ngql/GoPlanner.cpp index c4f5e7abe25..de245af60b4 100644 --- a/src/graph/planner/ngql/GoPlanner.cpp +++ b/src/graph/planner/ngql/GoPlanner.cpp @@ -482,7 +482,7 @@ SubPlan GoPlanner::nStepsPlan(SubPlan& startVidPlan) { } PlanNode* loopBody = getDst; - PlanNode* loopDep = nullptr; + PlanNode* loopDep = startVidPlan.root; if (goCtx_->joinInput) { auto* joinLeft = extractVidFromRuntimeInput(startVidPlan.root); auto* joinRight = extractSrcDstFromGN(getDst, sampleLimit->outputVar()); diff --git a/tests/tck/features/go/SimpleCase.feature b/tests/tck/features/go/SimpleCase.feature index 238c3955b40..c8dd2e7020b 100644 --- a/tests/tck/features/go/SimpleCase.feature +++ b/tests/tck/features/go/SimpleCase.feature @@ -240,3 +240,24 @@ Feature: Simple case | 2 | Dedup | 1 | | | 1 | GetDstBySrc | 0 | | | 0 | Start | | | + When profiling query: + """ + GO 1 STEP FROM "Tony Parker" OVER * YIELD distinct id($$) as id| GO 3 STEP FROM $-.id OVER * YIELD distinct id($$) | YIELD COUNT(*) + """ + Then the result should be, in any order, with relax comparison: + | COUNT(*) | + | 22 | + And the execution plan should be: + | id | name | dependencies | operator info | + | 11 | Aggregate | 10 | | + | 10 | Dedup | 9 | | + | 9 | GetDstBySrc | 8 | | + | 8 | Loop | 4 | {"loopBody": "7"} | + | 7 | Dedup | 6 | | + | 6 | GetDstBySrc | 5 | | + | 5 | Start | | | + | 4 | Dedup | 3 | | + | 3 | Project | 2 | | + | 2 | Dedup | 1 | | + | 1 | GetDstBySrc | 0 | | + | 0 | Start | | |