Compare commits

...

1 Commits

Author SHA1 Message Date
Andi Skrgat
c5af23ee23 Add clearing of property lookup cache 2023-12-01 09:03:33 +01:00
4 changed files with 41 additions and 4 deletions

View File

@@ -188,6 +188,8 @@ class ExpressionEvaluator : public ExpressionVisitor<TypedValue> {
utils::MemoryResource *GetMemoryResource() const { return ctx_->memory; }
void ClearPropertyLookupCache() { property_lookup_cache_.clear(); }
TypedValue Visit(NamedExpression &named_expression) override {
const auto &symbol = symbol_table_->at(named_expression);
auto value = named_expression.expression_->Accept(*this);

View File

@@ -3678,13 +3678,14 @@ class AggregateCursor : public Cursor {
for (; count_it != counts_end; ++count_it, ++value_it, ++unique_values_it, ++agg_elem_it) {
// COUNT(*) is the only case where input expression is optional
// handle it here
auto input_expr_ptr = agg_elem_it->value;
auto *input_expr_ptr = agg_elem_it->value;
if (!input_expr_ptr) {
*count_it += 1;
// value is deferred to post-processing
continue;
}
evaluator->ClearPropertyLookupCache();
TypedValue input_value = input_expr_ptr->Accept(*evaluator);
// Aggregations skip Null input values.

View File

@@ -422,7 +422,24 @@ Feature: Aggregations
CREATE (s:Subnet {ip: "192.168.0.1"})
"""
When executing query:
"""
MATCH (subnet:Subnet) WHERE FALSE WITH subnet, count(subnet.ip) as ips RETURN id(subnet) as id
"""
"""
MATCH (subnet:Subnet) WHERE FALSE WITH subnet, count(subnet.ip) as ips RETURN id(subnet) as id
"""
Then the result should be empty
Scenario: Collect nodes properties into a map:
Given an empty graph
And having executed
"""
CREATE (t:Tag {short_code: "TST", description: "SYSTEM_TAG"}), (t2:Tag {short_code: "PRD", description: "SYSTEM_TAG"}),
(t3:Tag {short_code: "STG", description: "SYSTEM_TAG"}), (device {name: "name1"}), (device)-[a1:ASSOCIATED]->(t),
(device)-[a2:ASSOCIATED]->(t2), (device)-[a3:ASSOCIATED]->(t3);
"""
When executing query:
"""
MATCH (d {name: "name1"})-[t:ASSOCIATED]-(tag:Tag) RETURN collect({short_code: tag.short_code, description: tag.description}) as tags;
"""
Then the result should be:
| tags |
| [{description: 'SYSTEM_TAG', short_code: 'TST'}, {description: 'SYSTEM_TAG', short_code: 'PRD'}, {description: 'SYSTEM_TAG', short_code: 'STG'}] |

View File

@@ -426,3 +426,20 @@ Feature: Aggregations
MATCH (subnet:Subnet) WHERE FALSE WITH subnet, count(subnet.ip) as ips RETURN id(subnet) as id
"""
Then the result should be empty
Scenario: Collect nodes properties into a map:
Given an empty graph
And having executed
"""
CREATE (t:Tag {short_code: "TST", description: "SYSTEM_TAG"}), (t2:Tag {short_code: "PRD", description: "SYSTEM_TAG"}),
(t3:Tag {short_code: "STG", description: "SYSTEM_TAG"}), (device {name: "name1"}), (device)-[a1:ASSOCIATED]->(t),
(device)-[a2:ASSOCIATED]->(t2), (device)-[a3:ASSOCIATED]->(t3);
"""
When executing query:
"""
MATCH (d {name: "name1"})-[t:ASSOCIATED]-(tag:Tag) RETURN collect({short_code: tag.short_code, description: tag.description}) as tags;
"""
Then the result should be:
| tags |
| [{description: 'SYSTEM_TAG', short_code: 'TST'}, {description: 'SYSTEM_TAG', short_code: 'PRD'}, {description: 'SYSTEM_TAG', short_code: 'STG'}] |