fix: erase extract() bound symbol in UsedSymbolsCollector - #4081
Merged
Conversation
UsedSymbolsCollector erases lambda-bound symbols in PostVisit overrides for All, Any, Single, None, Reduce and ListComprehension, but the override for Extract was missing. When extract() appears inside a WHERE expression, the bound iterator is incorrectly counted as a free symbol of the filter, so the filter never matches any expansion's bound symbols and PlanMatching ends with a non-empty filters set, throwing "Expected to generate all filters!". Adds the missing PostVisit(Extract&) override and a behave regression test covering both matching and non-matching IN extract() predicates. Closes #2023
|
DavIvek
marked this pull request as ready for review
August 17, 2026 07:03
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes a planner crash triggered by extract(v IN list | expr) used inside a WHERE clause by ensuring the lambda-bound iterator symbol (v) is treated as bound (not “free”) during symbol collection, so filter matching does not retain an unbindable symbol and trip an internal guard.
Changes:
- Add
UsedSymbolsCollector::PostVisit(Extract&)to erase the iterator symbol bound byextract(...). - Add new Gherkin/behave coverage reproducing the crash and validating correct behavior for matching and non-matching membership predicates.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
src/query/plan/preprocess.hpp |
Erases extract’s bound iterator symbol from UsedSymbolsCollector results, aligning with existing handling for other lambda-like expressions. |
tests/gql_behave/tests/memgraph_V1/features/issue_2023_extract_in_where.feature |
Adds regression scenarios covering IN extract(...) in WHERE for both matching and non-matching cases. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
imilinovic
approved these changes
Aug 17, 2026
DavIvek
enabled auto-merge
August 17, 2026 18:27
Contributor
Author
Tracking
Standard development
CI Testing Labels
Documentation checklist
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Description
Closes #2023
A WHERE clause that uses
extract(v IN list | expr)(and exercises the bound iterator insideexpr) crashes the planner with the internal error:Repro
The user-reported workaround (lifting
extract(...)into aWITHand filtering on the alias) still works.Root cause
UsedSymbolsCollectorinsrc/query/plan/preprocess.hppdefinesPostVisitoverrides that erase the lambda-bound symbol forAll,Any,Single,None,Reduce, andListComprehension. The override forExtractwas missing, so the iteratorvofextract(v IN list | expr)ended up in the filter'sused_symbols. Because no logical operator ever bindsv, the filter is never matched against any expansion andPlanMatchingends with a non-emptyfiltersset, tripping the guard inrule_based_planner.hpp:813.