Skip to content

Commit

Permalink
Fix filter push down project. (#4863)
Browse files Browse the repository at this point in the history
  • Loading branch information
Shylock-Hg authored Nov 11, 2022
1 parent 6d65a85 commit aa83e95
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 4 deletions.
5 changes: 1 addition & 4 deletions src/graph/optimizer/rule/PushFilterDownProjectRule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ StatusOr<OptRule::TransformResult> 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,
Expand All @@ -71,9 +70,7 @@ StatusOr<OptRule::TransformResult> 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;
Expand Down
29 changes: 29 additions & 0 deletions tests/tck/features/bugfix/PushFilterDownProject.feature
Original file line number Diff line number Diff line change
@@ -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 | | |

0 comments on commit aa83e95

Please sign in to comment.