From fd8d8a870fb5616cb67bbab95e7f3f1a20a3a1b9 Mon Sep 17 00:00:00 2001 From: shylock <33566796+Shylock-Hg@users.noreply.github.com> Date: Mon, 27 Dec 2021 15:34:41 +0800 Subject: [PATCH] Disable the bidirection edges (#3507) --- .../optimizer/rule/GetEdgesTransformRule.cpp | 15 +++++++++++++++ tests/tck/features/match/Scan.feature | 14 ++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/src/graph/optimizer/rule/GetEdgesTransformRule.cpp b/src/graph/optimizer/rule/GetEdgesTransformRule.cpp index df671fe5566..6fb31f56259 100644 --- a/src/graph/optimizer/rule/GetEdgesTransformRule.cpp +++ b/src/graph/optimizer/rule/GetEdgesTransformRule.cpp @@ -73,6 +73,9 @@ StatusOr GetEdgesTransformRule::transform( OptGroupNode::create(ctx, newAppendVertices, appendVerticesGroupNode->group()); auto *newScanEdges = traverseToScanEdges(traverse); + if (newScanEdges == nullptr) { + return TransformResult::noTransform(); + } auto newScanEdgesGroup = OptGroup::create(ctx); auto newScanEdgesGroupNode = newScanEdgesGroup->makeGroupNode(newScanEdges); @@ -102,6 +105,18 @@ std::string GetEdgesTransformRule::toString() const { /*static*/ graph::ScanEdges *GetEdgesTransformRule::traverseToScanEdges( const graph::Traverse *traverse) { const auto *edgeProps = traverse->edgeProps(); + if (edgeProps == nullptr) { + return nullptr; + } + for (std::size_t i = 0; i < edgeProps->size(); i++) { + auto type = (*edgeProps)[i].get_type(); + for (std::size_t j = i + 1; j < edgeProps->size(); j++) { + if (type == -((*edgeProps)[j].get_type())) { + // Don't support to retrieve edges of the inbound/outbound together + return nullptr; + } + } + } auto scanEdges = ScanEdges::make( traverse->qctx(), nullptr, diff --git a/tests/tck/features/match/Scan.feature b/tests/tck/features/match/Scan.feature index faf8e5cded3..5204849b9b8 100644 --- a/tests/tck/features/match/Scan.feature +++ b/tests/tck/features/match/Scan.feature @@ -155,3 +155,17 @@ Feature: Match seek by scan LIMIT 3 """ Then a ExecutionError should be raised at runtime: Scan vertices must specify limit number. + When executing query: + """ + MATCH ()-[e:is_teacher]-() + RETURN type(e) AS Type, e.start_year AS StartYear, e.end_year AS EndYear + LIMIT 3 + """ + Then a ExecutionError should be raised at runtime: Scan vertices must specify limit number. + When executing query: + """ + MATCH ()-[e]-() + RETURN type(e) AS Type, e.start_year AS StartYear, e.end_year AS EndYear + LIMIT 3 + """ + Then a ExecutionError should be raised at runtime: Scan vertices must specify limit number.