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

Remove the pruning of Expression::Kind::kVarProperty in agg. #4990

Merged
merged 3 commits into from
Dec 6, 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
3 changes: 1 addition & 2 deletions src/graph/visitor/PropertyTrackerVisitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -317,8 +317,7 @@ void PropertyTrackerVisitor::visit(AggregateExpression *expr) {
std::transform(funName.begin(), funName.end(), funName.begin(), ::tolower);
if (funName == "count") {
auto kind = expr->arg()->kind();
if (kind == Expression::Kind::kConstant || kind == Expression::Kind::kInputProperty ||
kind == Expression::Kind::kVarProperty) {
if (kind == Expression::Kind::kConstant) {
return;
}
}
Expand Down
124 changes: 95 additions & 29 deletions tests/tck/features/optimizer/PrunePropertiesRule.feature
Original file line number Diff line number Diff line change
Expand Up @@ -422,14 +422,14 @@ Feature: Prune Properties rule
| count(v2) |
| 24 |
And the execution plan should be:
| id | name | dependencies | operator info |
| 7 | Aggregate | 6 | |
| 6 | Project | 5 | |
| 5 | AppendVertices | 4 | { "props": "[{\"props\":[\"_tag\"],\"tagId\":8}, {\"props\":[\"_tag\"],\"tagId\":9}, {\"props\":[\"_tag\"],\"tagId\":10}]" } |
| 4 | Traverse | 2 | {"vertexProps": "", "edgeProps": "[{\"type\": 3, \"props\": [\"_type\", \"_rank\", \"_dst\"]}]" } |
| 2 | Dedup | 1 | |
| 1 | PassThrough | 3 | |
| 3 | Start | | |
| id | name | dependencies | operator info |
| 7 | Aggregate | 6 | |
| 6 | Project | 5 | |
| 5 | AppendVertices | 4 | { "props": "[{\"tagId\":8,\"props\":[\"name\",\"speciality\",\"_tag\"]},{\"props\":[\"_tag\",\"name\",\"age\"],\"tagId\":9},{\"tagId\":10,\"props\":[\"name\",\"_tag\"]}]" } |
| 4 | Traverse | 2 | {"vertexProps": "", "edgeProps": "[{\"type\": 3, \"props\": [\"_type\", \"_rank\", \"_dst\"]}]" } |
| 2 | Dedup | 1 | |
| 1 | PassThrough | 3 | |
| 3 | Start | | |
When profiling query:
"""
MATCH p = (v1)-[e:like*1..5]->(v2)
Expand Down Expand Up @@ -533,27 +533,27 @@ Feature: Prune Properties rule
| "Spurs" | 11 |
| "Hornets" | 3 |
And the execution plan should be:
| id | name | dependencies | operator info |
| 21 | Aggregate | 20 | |
| 20 | Aggregate | 19 | |
| 19 | HashLeftJoin | 10, 25 | |
| 10 | Aggregate | 23 | |
| 23 | Project | 22 | |
| 22 | Filter | 29 | |
| 29 | AppendVertices | 28 | { "props": "[{\"props\":[\"name\", \"_tag\"],\"tagId\":10}]" } |
| 28 | Traverse | 27 | {"vertexProps": "[{\"props\":[\"age\"],\"tagId\":9}]", "edgeProps": "[{\"type\": 4, \"props\": [\"_type\", \"_rank\", \"_dst\"]}]" } |
| 27 | Traverse | 26 | {"vertexProps": "", "edgeProps": "[{\"type\": -5, \"props\": [\"_type\", \"_rank\", \"_dst\"]}]" } |
| 26 | Traverse | 2 | {"vertexProps": "", "edgeProps": "[{\"type\": -3, \"props\": [\"_type\", \"_rank\", \"_dst\"]}, {\"type\": 3, \"props\": [\"_type\", \"_rank\", \"_dst\"]}]" } |
| 2 | Dedup | 1 | |
| 1 | PassThrough | 3 | |
| 3 | Start | | |
| 25 | Project | 24 | |
| 24 | Filter | 16 | |
| 16 | AppendVertices | 15 | { "props": "[{\"props\":[\"name\", \"_tag\"],\"tagId\":10}]" } |
| 15 | Traverse | 14 | {"vertexProps": "[{\"props\":[\"age\"],\"tagId\":9}]", "edgeProps": "[{\"type\": 4, \"props\": [\"_type\", \"_rank\", \"_dst\"]}]" } |
| 14 | Traverse | 13 | {"vertexProps": "", "edgeProps": "[{\"type\": -3, \"props\": [\"_type\", \"_rank\", \"_dst\"]}]" } |
| 13 | Traverse | 11 | {"vertexProps": "", "edgeProps": "[{\"type\": -3, \"props\": [\"_type\", \"_rank\", \"_dst\"]}, {\"type\": 3, \"props\": [\"_type\", \"_rank\", \"_dst\"]}]" } |
| 11 | Argument | | |
| id | name | dependencies | operator info |
| 21 | Aggregate | 20 | |
| 20 | Aggregate | 19 | |
| 19 | HashLeftJoin | 10, 25 | |
| 10 | Aggregate | 23 | |
| 23 | Project | 22 | |
| 22 | Filter | 29 | |
| 29 | AppendVertices | 28 | { "props": "[{\"props\":[\"name\", \"_tag\"],\"tagId\":10}]" } |
| 28 | Traverse | 27 | {"vertexProps": "[{\"tagId\":8,\"props\":[\"name\",\"speciality\",\"_tag\"]},{\"tagId\":9,\"props\":[\"name\",\"age\",\"_tag\"]},{\"props\":[\"name\",\"_tag\"],\"tagId\":10}]", "edgeProps": "[{\"type\":4,\"props\":[\"_dst\",\"_type\",\"_rank\"]}]"} |
| 27 | Traverse | 26 | {"vertexProps": "", "edgeProps": "[{\"type\": -5, \"props\": [\"_type\", \"_rank\", \"_dst\"]}]" } |
| 26 | Traverse | 2 | {"vertexProps": "", "edgeProps": "[{\"type\": -3, \"props\": [\"_type\", \"_rank\", \"_dst\"]}, {\"type\": 3, \"props\": [\"_type\", \"_rank\", \"_dst\"]}]" } |
| 2 | Dedup | 1 | |
| 1 | PassThrough | 3 | |
| 3 | Start | | |
| 25 | Project | 24 | |
| 24 | Filter | 16 | |
| 16 | AppendVertices | 15 | { "props": "[{\"props\":[\"name\", \"_tag\"],\"tagId\":10}]" } |
| 15 | Traverse | 14 | {"vertexProps": "[{\"tagId\":8,\"props\":[\"name\",\"speciality\",\"_tag\"]},{\"tagId\":9,\"props\":[\"name\",\"age\",\"_tag\"]},{\"props\":[\"name\",\"_tag\"],\"tagId\":10}]", "edgeProps": "[{\"type\":4,\"props\":[\"_dst\",\"_type\",\"_rank\"]}]"} |
| 14 | Traverse | 13 | {"vertexProps": "", "edgeProps": "[{\"type\": -3, \"props\": [\"_type\", \"_rank\", \"_dst\"]}]" } |
| 13 | Traverse | 11 | {"vertexProps": "", "edgeProps": "[{\"type\": -3, \"props\": [\"_type\", \"_rank\", \"_dst\"]}, {\"type\": 3, \"props\": [\"_type\", \"_rank\", \"_dst\"]}]" } |
| 11 | Argument | | |

@distonly
Scenario: test properties:
Expand Down Expand Up @@ -878,3 +878,69 @@ Feature: Prune Properties rule
| v.player.name | t.errortag.name | properties(v) | t |
| "Tim Duncan" | __NULL__ | {age: 42, name: "Tim Duncan", speciality: "psychology"} | ("Tony Parker" :player{age: 36, name: "Tony Parker"}) |
| "Tim Duncan" | __NULL__ | {age: 42, name: "Tim Duncan", speciality: "psychology"} | ("Manu Ginobili" :player{age: 41, name: "Manu Ginobili"}) |

Scenario: no pruning on agg after unwind
Given a graph with space named "nba"
When executing query:
"""
match (v0:player)-[e0]->(v1) where id(v0) == "Tim Duncan" unwind e0.start_year as a return count(a)
"""
Then the result should be, in any order:
| count(a) |
| 5 |
When executing query:
"""
match (v0:player)-[e0]->(v1) where id(v0) == "Tim Duncan" unwind e0.start_year as a return sum(a)
"""
Then the result should be, in any order:
| sum(a) |
| 10025 |
When executing query:
"""
match (v0:player)-[e0]->(v1) where id(v0) == "Tim Duncan" unwind e0.start_year as a return max(a)
"""
Then the result should be, in any order:
| max(a) |
| 2015 |
When executing query:
"""
match (v0:player)-[e0]->(v1) where id(v0) == "Tim Duncan" unwind e0.start_year as a return min(a)
"""
Then the result should be, in any order:
| min(a) |
| 1997 |
When executing query:
"""
match (v0:player)-[e0]->(v1) where id(v0) == "Tim Duncan" unwind e0.start_year as a return avg(a)
"""
Then the result should be, in any order:
| avg(a) |
| 2005.0 |
When executing query:
"""
match (v0:player)-[e0]->(v1) where id(v0) == "Tim Duncan" unwind e0.start_year as a return std(a)
"""
Then the result should be, in any order:
| std(a) |
| 6.542170893518461 |
When executing query:
"""
match (v0:player)-[e0]->(v1) where id(v0) == "Tim Duncan" unwind e0.start_year as a return std(a)
"""
Then the result should be, in any order:
| std(a) |
| 6.542170893518461 |
When executing query:
"""
match (v0:player)-[e0]->(v1) where id(v0) == "Tim Duncan" unwind e0.start_year as a return bit_or(a)
"""
Then the result should be, in any order:
| bit_or(a) |
| 2015 |
When executing query:
"""
match (v0:player)-[e0]->(v1) where id(v0) == "Tim Duncan" unwind e0.start_year as a return bit_and(a)
"""
Then the result should be, in any order:
| bit_and(a) |
| 1984 |