From aa83e95be863d4534182ad1edc4b9fa8e90fbe0a Mon Sep 17 00:00:00 2001 From: shylock <33566796+Shylock-Hg@users.noreply.github.com> Date: Fri, 11 Nov 2022 15:20:19 +0800 Subject: [PATCH] Fix filter push down project. (#4863) --- .../rule/PushFilterDownProjectRule.cpp | 5 +--- .../bugfix/PushFilterDownProject.feature | 29 +++++++++++++++++++ 2 files changed, 30 insertions(+), 4 deletions(-) create mode 100644 tests/tck/features/bugfix/PushFilterDownProject.feature diff --git a/src/graph/optimizer/rule/PushFilterDownProjectRule.cpp b/src/graph/optimizer/rule/PushFilterDownProjectRule.cpp index d14fe98ee78..ef26098c775 100644 --- a/src/graph/optimizer/rule/PushFilterDownProjectRule.cpp +++ b/src/graph/optimizer/rule/PushFilterDownProjectRule.cpp @@ -49,7 +49,6 @@ StatusOr PushFilterDownProjectRule::transform( auto picker = [&projColumns, &projColNames, &rewriteMap](const Expression* e) -> bool { auto varProps = graph::ExpressionUtils::collectAll(e, {Expression::Kind::kTagProperty, - Expression::Kind::kLabelTagProperty, Expression::Kind::kEdgeProperty, Expression::Kind::kInputProperty, Expression::Kind::kVarProperty, @@ -71,9 +70,7 @@ StatusOr PushFilterDownProjectRule::transform( }); if (iter == propNames.end()) continue; if (graph::ExpressionUtils::isPropertyExpr(column->expr())) { - if (!column->alias().empty()) { - rewriteMap[colName] = column->expr(); - } + rewriteMap[colName] = column->expr(); continue; } else { return false; diff --git a/tests/tck/features/bugfix/PushFilterDownProject.feature b/tests/tck/features/bugfix/PushFilterDownProject.feature new file mode 100644 index 00000000000..832654cc890 --- /dev/null +++ b/tests/tck/features/bugfix/PushFilterDownProject.feature @@ -0,0 +1,29 @@ +# Copyright (c) 2022 vesoft inc. All rights reserved. +# +# This source code is licensed under Apache 2.0 License. +Feature: Test push filter down project + + Background: + Given a graph with space named "nba" + + Scenario: push filter down project + When profiling query: + """ + MATCH (n0)-[:like]->(n1) + WHERE (id(n0) IN ["Tim Duncan"]) + WITH n1.player.age AS a0 + WHERE ((a0 - (a0 + ((a0 % a0) + (a0 + a0)))) <= a0) RETURN count(*) + """ + Then the result should be, in any order: + | count(*) | + | 2 | + And the execution plan should be: + | id | name | dependencies | operator info | + | 9 | Aggregate | 12 | | + | 12 | Project | 11 | | + | 11 | Filter | 5 | {"condition": "((-.n1.player.age-(-.n1.player.age+((-.n1.player.age%-.n1.player.age)+(-.n1.player.age+-.n1.player.age))))<=-.n1.player.age)"} | + | 5 | AppendVertices | 4 | | + | 4 | Traverse | 2 | | + | 2 | Dedup | 1 | | + | 1 | PassThrough | 3 | | + | 3 | Start | | |