Skip to content

Allow output aliases that shadow a variable #21

Closed

Description

@prrao87

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.

Activity

  1. prrao87 commented on Oct 27, 2026

    @prrao87
    MemberAuthor

    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 on dbb8e9f, with and without use_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 q and WITH p.name AS p, count(*) AS c all return correct results.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions