Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix filter push down project. #4863

Merged
merged 2 commits into from
Nov 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 | | |