From 90659640827358951876a588c62a677ba42b6e1c Mon Sep 17 00:00:00 2001 From: Shylock Hg <33566796+Shylock-Hg@users.noreply.github.com> Date: Fri, 30 Dec 2022 16:47:52 +0800 Subject: [PATCH] Fix scan efilter. --- ...tEdgesTransformAppendVerticesLimitRule.cpp | 8 ++++++ .../optimizer/rule/GetEdgesTransformRule.cpp | 8 ++++++ .../bugfix/LackFilterGetEdges.feature | 25 +++++++++++++++++++ 3 files changed, 41 insertions(+) create mode 100644 tests/tck/features/bugfix/LackFilterGetEdges.feature diff --git a/src/graph/optimizer/rule/GetEdgesTransformAppendVerticesLimitRule.cpp b/src/graph/optimizer/rule/GetEdgesTransformAppendVerticesLimitRule.cpp index f12f346b673..cb7db5d8175 100644 --- a/src/graph/optimizer/rule/GetEdgesTransformAppendVerticesLimitRule.cpp +++ b/src/graph/optimizer/rule/GetEdgesTransformAppendVerticesLimitRule.cpp @@ -61,6 +61,14 @@ bool GetEdgesTransformAppendVerticesLimitRule::match(OptContext *ctx, if (traverse->stepRange() != nullptr) { return false; } + // Can't apply vertex filter in GetEdges + if (traverse->vFilter() != nullptr) { + return false; + } + // If edge filter is not null, means it's can't be pushed down to storage + if (traverse->eFilter() != nullptr) { + return false; + } for (auto yieldColumn : project->columns()->columns()) { // exclude p=()-[e]->() return p limit 10 if (yieldColumn->expr()->kind() == nebula::Expression::Kind::kPathBuild) { diff --git a/src/graph/optimizer/rule/GetEdgesTransformRule.cpp b/src/graph/optimizer/rule/GetEdgesTransformRule.cpp index 5df8b26744f..17764389c2b 100644 --- a/src/graph/optimizer/rule/GetEdgesTransformRule.cpp +++ b/src/graph/optimizer/rule/GetEdgesTransformRule.cpp @@ -57,6 +57,14 @@ bool GetEdgesTransformRule::match(OptContext *ctx, const MatchedResult &matched) if (traverse->stepRange() != nullptr) { return false; } + // Can't apply vertex filter in GetEdges + if (traverse->vFilter() != nullptr) { + return false; + } + // If edge filter is not null, means it's can't be pushed down to storage + if (traverse->eFilter() != nullptr) { + return false; + } for (auto yieldColumn : project->columns()->columns()) { // exclude p=()-[e]->() return p limit 10 if (yieldColumn->expr()->kind() == nebula::Expression::Kind::kPathBuild) { diff --git a/tests/tck/features/bugfix/LackFilterGetEdges.feature b/tests/tck/features/bugfix/LackFilterGetEdges.feature new file mode 100644 index 00000000000..cd4b2c874a0 --- /dev/null +++ b/tests/tck/features/bugfix/LackFilterGetEdges.feature @@ -0,0 +1,25 @@ +# Copyright (c) 2022 vesoft inc. All rights reserved. +# +# This source code is licensed under Apache 2.0 License. +Feature: Test lack filter of get edges transform + + Background: + Given a graph with space named "nba" + + # #5145 + Scenario: Lack filter of get edges transform + When profiling query: + """ + match ()-[e]->() + where e.likeness > 78 or uuid() > 100 + return rank(e) limit 3 + """ + Then a ExecutionError should be raised at runtime: Scan vertices or edges need to specify a limit number, or limit number can not push down. + And the execution plan should be: + | id | name | dependencies | operator info | + | 24 | Project | 20 | | + | 20 | Limit | 21 | | + | 21 | AppendVertices | 23 | | + | 23 | Traverse | 22 | { "edge filter": "((*.likeness>78) OR (uuid()>100))"} | + | 22 | ScanVertices | 3 | | + | 3 | Start | | |