diff --git a/src/query/plan/preprocess.cpp b/src/query/plan/preprocess.cpp index 823850b91..0cfaf7202 100644 --- a/src/query/plan/preprocess.cpp +++ b/src/query/plan/preprocess.cpp @@ -684,9 +684,8 @@ static void ParseForeach(query::Foreach &foreach, SingleQueryPart &query_part, A static void ParseReturn(query::Return &ret, AstStorage &storage, SymbolTable &symbol_table, std::unordered_map &matchings) { - PatternVisitor visitor(symbol_table, storage); - for (auto *expr : ret.body_.named_expressions) { + PatternVisitor visitor(symbol_table, storage); expr->Accept(visitor); auto pattern_comprehension_matchings = visitor.getPatternComprehensionMatchings(); for (auto &matching : pattern_comprehension_matchings) { diff --git a/src/query/plan/rule_based_planner.cpp b/src/query/plan/rule_based_planner.cpp index c6209ede1..3851774e5 100644 --- a/src/query/plan/rule_based_planner.cpp +++ b/src/query/plan/rule_based_planner.cpp @@ -59,13 +59,10 @@ class ReturnBodyContext : public HierarchicalTreeVisitor { named_expressions_.emplace_back(named_expr); // Pattern comprehension can be filled during named expression traversion - if (has_pattern_comprehension()) { - if (auto it = pc_ops.find(named_expr->name_); it != pc_ops.end()) { - pattern_comprehension_data_.op = std::move(it->second.op); - pc_ops.erase(it); - } else { - throw utils::NotYetImplemented("Operation on top of pattern comprehension"); - } + if (auto it = pc_ops.find(named_expr->name_); it != pc_ops.end()) { + MG_ASSERT(pattern_comprehension_data_.pattern_comprehension != nullptr); + pattern_comprehension_data_.op = std::move(it->second.op); + pc_ops.erase(it); } } // Collect symbols used in group by expressions. diff --git a/tests/gql_behave/tests/memgraph_V1/features/list_operations.feature b/tests/gql_behave/tests/memgraph_V1/features/list_operations.feature index 9e3f06b34..b9c380146 100644 --- a/tests/gql_behave/tests/memgraph_V1/features/list_operations.feature +++ b/tests/gql_behave/tests/memgraph_V1/features/list_operations.feature @@ -302,6 +302,17 @@ Feature: List operators | years | keanu.name | | [2003, 2003, 1999, 2021] | "Keanu Reeves" | + Scenario: List pattern comprehension and property + Given graph "graph_keanu" + When executing query: + """ + MATCH (keanu:Person {name: 'Keanu Reeves'}) + RETURN [(keanu)-->(b:Movie) WHERE b.title CONTAINS 'Matrix' | size(b.title)] AS movie_lens; + """ + Then the result should be: + | movie_lens | + | [22, 19, 10, 24] | + Scenario: Multiple entries with list pattern comprehension Given graph "graph_keanu" When executing query: