feat(ir): RETURN * projects all in-scope variables (#598)#897
Merged
Conversation
`MATCH (a)-->(b) RETURN *` now returns one column per in-scope named
variable instead of erroring ("variable `*` used before it was
introduced"). The binder expands the `*` return item (it parses as a
`Var` named "*") to the current named vars from scope, sorted for a
deterministic plan; each expands to the normal per-var projection, so
node vars materialize as whole node values (#785).
Combined with WITH whole-node forwarding (#814 slice 2) and
MATCH-after-WITH, the With1 shape `MATCH (a) WITH a MATCH (a)-->(b)
RETURN *` now works end-to-end.
Anonymous pattern elements (no user name) aren't in scope and so aren't
returned; named relationship/path vars would expand but still fail
downstream (rel/path values unsupported) rather than being silently
dropped.
Validated: new e2e `return_star_projects_all_in_scope_vars`,
`return_star_after_with_forwarded_node` (87 pass); IR/rel goldens
unchanged; clippy --workspace -D warnings + fmt clean.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Contributor
WalkthroughImplements ChangesRETURN * Wildcard Expansion
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
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.
Advances #598 (read-path). The last engine piece for the
With1cluster.Summary
MATCH (a)-->(b) RETURN *now returns one column per in-scope named variable instead of erroring (variable*used before it was introduced).*parses as aVarnamed"*"; the binder now expands it to the current named vars from scope (sorted → deterministic plan), each lowered as the normal per-var projection — so node vars materialize as whole node values (#785).Combined with WITH whole-node forwarding (#814 slice 2) + MATCH-after-WITH, the
With1shapeMATCH (a) WITH a MATCH (a)-->(b) RETURN *now works end-to-end.Scope
Validation
return_star_projects_all_in_scope_vars(columnsa+b, node values),return_star_after_with_forwarded_node(the With1 MATCH-after-WITH shape) — 87 pass.cargo clippy --workspace -- -D warnings+ fmt clean.With this on main, #889 slice 2 (render + un-skip) finally has a runnable node-returning corpus cluster to land against.
🤖 Generated with Claude Code
Note
Expand
RETURN *to project all in-scope named variables in the IR binderexpand_return_wildcardin binder.rs to detect aVarnamed"*"in return items and replace it with one item per in-scope named variable fromBinderState.vars, sorted for deterministic ordering.Binder.lower_returnnow calls this expansion before aggregate detection and lowering, so wildcard projections resolve correctly instead of propagating a raw"*"variable.RETURN *afterMATCHandRETURN *afterWITHnode forwarding.Macroscope summarized 39a7a3c.
Summary by CodeRabbit
Tests
RETURN *behavior, validating proper projection of all in-scope variables as individual columns and correct handling inWITHclause scenarios with variable re-matching.Bug Fixes
RETURN *wildcard expansion to systematically include all named variables currently in scope in query results, sorted alphabetically.