From 6b072db848c8bbc5e6c8f971edf59b335969edda Mon Sep 17 00:00:00 2001 From: jimingquan Date: Mon, 24 Oct 2022 17:36:15 +0800 Subject: [PATCH 1/3] fix subgraph step --- src/graph/executor/algo/SubgraphExecutor.cpp | 7 +------ src/graph/planner/ngql/SubgraphPlanner.cpp | 4 ---- tests/tck/features/subgraph/subgraph.IntVid.feature | 8 ++++++++ tests/tck/features/subgraph/subgraph.feature | 8 ++++++++ tests/tck/features/subgraph/subgraphWithFilter.feature | 8 ++++++++ 5 files changed, 25 insertions(+), 10 deletions(-) diff --git a/src/graph/executor/algo/SubgraphExecutor.cpp b/src/graph/executor/algo/SubgraphExecutor.cpp index 826b5c1d86c..4a05a4a6b75 100644 --- a/src/graph/executor/algo/SubgraphExecutor.cpp +++ b/src/graph/executor/algo/SubgraphExecutor.cpp @@ -92,12 +92,7 @@ folly::Future SubgraphExecutor::handleResponse(RpcResponse&& resps) { auto listVal = std::make_shared(std::move(list)); auto iter = std::make_unique(listVal); - auto steps = totalSteps_; - if (!subgraph_->oneMoreStep()) { - --steps; - } - - if (!process(std::move(iter)) || ++currentStep_ > steps) { + if (!process(std::move(iter)) || ++currentStep_ > totalSteps_) { filterEdges(0); return folly::makeFuture(Status::OK()); } else { diff --git a/src/graph/planner/ngql/SubgraphPlanner.cpp b/src/graph/planner/ngql/SubgraphPlanner.cpp index c7b480f7136..f79b08393fc 100644 --- a/src/graph/planner/ngql/SubgraphPlanner.cpp +++ b/src/graph/planner/ngql/SubgraphPlanner.cpp @@ -69,7 +69,6 @@ StatusOr>> SubgraphPlanner::buildEdgeProps StatusOr SubgraphPlanner::nSteps(SubPlan& startVidPlan, const std::string& input) { auto* qctx = subgraphCtx_->qctx; const auto& space = subgraphCtx_->space; - const auto& dstTagProps = subgraphCtx_->exprProps.dstTagProps(); const auto& steps = subgraphCtx_->steps; auto vertexProps = buildVertexProps(); @@ -89,9 +88,6 @@ StatusOr SubgraphPlanner::nSteps(SubPlan& startVidPlan, const std::stri subgraph->setEdgeProps(std::move(edgeProps).value()); subgraph->setInputVar(input); subgraph->setBiDirectEdgeTypes(subgraphCtx_->biDirectEdgeTypes); - if (subgraphCtx_->getEdgeProp || subgraphCtx_->withProp || !dstTagProps.empty()) { - subgraph->setOneMoreStep(); - } auto* dc = DataCollect::make(qctx, DataCollect::DCKind::kSubgraph); dc->addDep(subgraph); diff --git a/tests/tck/features/subgraph/subgraph.IntVid.feature b/tests/tck/features/subgraph/subgraph.IntVid.feature index e70c30ae9f1..390aae3747e 100644 --- a/tests/tck/features/subgraph/subgraph.IntVid.feature +++ b/tests/tck/features/subgraph/subgraph.IntVid.feature @@ -145,6 +145,14 @@ Feature: Integer Vid subgraph | nodes | relationships | | [("Tim Duncan")] | <[edge1]> | | <[vertex2]> | <[edge2]> | + When executing query: + """ + GET SUBGRAPH FROM hash('Tim Duncan') OUT like YIELD vertices as v + """ + Then the result should be, in any order, with relax comparison: + | v | + | [("Tim Duncan")] | + | [("Manu Ginobili"), ("Tony Parker")] | Scenario: yield Integer Vid two steps When executing query: diff --git a/tests/tck/features/subgraph/subgraph.feature b/tests/tck/features/subgraph/subgraph.feature index e33ecd62c08..4951352eee1 100644 --- a/tests/tck/features/subgraph/subgraph.feature +++ b/tests/tck/features/subgraph/subgraph.feature @@ -145,6 +145,14 @@ Feature: subgraph | nodes | relationships | | [("Tim Duncan")] | <[edge1]> | | <[vertex2]> | <[edge2]> | + When executing query: + """ + GET SUBGRAPH FROM 'Tim Duncan' OUT like YIELD vertices as v + """ + Then the result should be, in any order, with relax comparison: + | v | + | [("Tim Duncan")] | + | [("Manu Ginobili"), ("Tony Parker")] | Scenario: two steps When executing query: diff --git a/tests/tck/features/subgraph/subgraphWithFilter.feature b/tests/tck/features/subgraph/subgraphWithFilter.feature index c5793a5ced5..97afffab724 100644 --- a/tests/tck/features/subgraph/subgraphWithFilter.feature +++ b/tests/tck/features/subgraph/subgraphWithFilter.feature @@ -7,6 +7,14 @@ Feature: subgraph with fitler Given a graph with space named "nba" Scenario: subgraph with edge filter + When executing query: + """ + GET SUBGRAPH FROM 'Tim Duncan' OUT like WHERE like.likeness > 90 YIELD vertices as v + """ + Then the result should be, in any order, with relax comparison: + | v | + | [("Tim Duncan")] | + | [("Manu Ginobili"), ("Tony Parker")] | When executing query: """ GET SUBGRAPH FROM 'Tim Duncan' OUT like WHERE like.likeness > 90 YIELD vertices as v, edges as e From 972097e17d56bef11ba972603eadb4382844f81e Mon Sep 17 00:00:00 2001 From: jimingquan Date: Mon, 24 Oct 2022 17:44:19 +0800 Subject: [PATCH 2/3] forbid function call in where clause --- src/graph/validator/GetSubgraphValidator.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/graph/validator/GetSubgraphValidator.cpp b/src/graph/validator/GetSubgraphValidator.cpp index e2350c1d326..f8b9f4bbc76 100644 --- a/src/graph/validator/GetSubgraphValidator.cpp +++ b/src/graph/validator/GetSubgraphValidator.cpp @@ -127,6 +127,7 @@ Status GetSubgraphValidator::validateWhere(WhereClause* where) { Expression::Kind::kSrcProperty, Expression::Kind::kVarProperty, Expression::Kind::kInputProperty, + Expression::Kind::kFunctionCall, Expression::Kind::kLogicalOr})) { return Status::SemanticError("Not support `%s' in where sentence.", expr->toString().c_str()); } From 61ff5c3e68275be3a704e7842351c47504952a64 Mon Sep 17 00:00:00 2001 From: jimingquan Date: Tue, 25 Oct 2022 14:14:37 +0800 Subject: [PATCH 3/3] fix error --- src/graph/validator/GetSubgraphValidator.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/graph/validator/GetSubgraphValidator.cpp b/src/graph/validator/GetSubgraphValidator.cpp index f8b9f4bbc76..e2350c1d326 100644 --- a/src/graph/validator/GetSubgraphValidator.cpp +++ b/src/graph/validator/GetSubgraphValidator.cpp @@ -127,7 +127,6 @@ Status GetSubgraphValidator::validateWhere(WhereClause* where) { Expression::Kind::kSrcProperty, Expression::Kind::kVarProperty, Expression::Kind::kInputProperty, - Expression::Kind::kFunctionCall, Expression::Kind::kLogicalOr})) { return Status::SemanticError("Not support `%s' in where sentence.", expr->toString().c_str()); }