Skip to content

Commit

Permalink
Removed a case in pruning properties on aggregation. Allowd counting …
Browse files Browse the repository at this point in the history
…nulls.
  • Loading branch information
xtcyclist committed Dec 5, 2022
1 parent 04ea700 commit 6ee10a5
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/common/function/AggFunctionManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ AggFunctionManager::AggFunctionManager() {
if (res.isNull()) {
res = 0;
}
if (val.isNull() || val.empty()) {
if (val.empty()) {
return;
}

Expand Down
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 || kind == Expression::Kind::kInputProperty) {
return;
}
}
Expand Down
10 changes: 10 additions & 0 deletions tests/tck/features/optimizer/PrunePropertiesRule.feature
Original file line number Diff line number Diff line change
Expand Up @@ -878,3 +878,13 @@ 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 |

0 comments on commit 6ee10a5

Please sign in to comment.