From 87e291a46fe4b1ed9a7a917a33be3b687aaba58d Mon Sep 17 00:00:00 2001 From: Shylock Hg <33566796+Shylock-Hg@users.noreply.github.com> Date: Mon, 20 Dec 2021 19:19:46 +0800 Subject: [PATCH] Disable the bidirection edges. --- .../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 bfa8456c57a..158e4df7620 100644 --- a/src/graph/optimizer/rule/GetEdgesTransformRule.cpp +++ b/src/graph/optimizer/rule/GetEdgesTransformRule.cpp @@ -71,6 +71,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); @@ -98,6 +101,18 @@ std::string GetEdgesTransformRule::toString() const { return "GetEdgesTransformR /*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.