Allow output aliases that shadow a variable #21
Copy link
Copy link
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
Problem
An output alias that reuses a variable's name, such as RETURN p.name AS p, can fail to plan once the query also aggregates or uses OPTIONAL MATCH. This is documented as a known issue in docs/cypher.md but not tracked.
Shadowing a variable with an alias is valid Cypher and common in hand-written queries.
Evidence
Documented in docs/cypher.md; a minimal reproduction should be the first step.
Suggested fix
Reproduce with a small graph, then find where the alias and the variable collide: likely when output columns are named after aliases while the variable's qualified columns are still in scope for the aggregation or the left join. Resolve aliases to distinct internal names and rename only at the final projection.
Acceptance criteria
- A minimal failing test, in Rust or Python, that passes after the fix, covering aggregation and
OPTIONAL MATCH. - The known-issue note is removed from
docs/cypher.md.
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working
Activity
fix(query): resolve shadowing output aliases in sort (#49)
Add Cypher string and list scalar functions (#43)
Add numeric scalar functions with strict Cypher types (#42)
feat(cypher): bind parameters in SKIP and LIMIT (#41)
feat(cypher): support typed list and map parameters (#40)
feat: integrate cypher, csr and engine work for 0.3.0 (#55)
prrao87 commentedon Oct 27, 2026
Fixed on main by #55, which added regression tests for this issue, and the known-issue note is gone from
docs/cypher.md. Checked again ondbb8e9f, with and withoutuse_csr:RETURN p.name AS p, count(*),OPTIONAL MATCH ... RETURN p.name AS p, q.name AS q,OPTIONAL MATCH ... RETURN p.name AS p, count(q) AS qandWITH p.name AS p, count(*) AS call return correct results.