Skip to content

fix(rel): UNWIND of maps feeding two inline-map node patterns fails in optimize_projections #2084

Closed

Description

@DecisionNerd

Defect

A read that unwinds a list of maps and uses two of the map's fields as inline node properties in one MATCH fails at planning time. It returns no rows and raises an optimizer error.

UNWIND [{a: 1, b: 2}] AS e
MATCH (a:N {id: e.a}), (b:N {id: e.b})
RETURN a.name, b.name

The error:

Optimizer rule 'optimize_projections' failed ... No field named var_1.name.
Valid fields are __datafusion_extracted_1, var_1.id, var_2.id

With RETURN count(*), the same pattern fails with No field named var_2.node_id.

Found during #1982. The introducing commit is being bisected, and the result will be added here.

Acceptance criteria

Activity

  1. DecisionNerd commented on Oct 14, 2026

    @DecisionNerd
    ContributorAuthor

    Root cause (pinned with a per-rule optimizer observer by another session on 2026-10-14):

    The fault is in DataFusion 53/54's extract_leaf_expressions and push_down_leaf_projections rule pair, not in GraphForge's demand code and not #2041. The lowered plan is correct and carries var_1.name, var_2.name and node_id.

    1. The two join keys are get_field(var_0,'a') = var_1.id and get_field(var_0,'b') = var_2.id, where var_0 is the unwound map.
    2. extract_leaf_expressions aliases both get_field calls as __datafusion_extracted_N.
    3. push_down_leaf_projections moves both extraction projections onto the Unwind side.
    4. optimize_projections then fails.

    Removing either rule makes optimization succeed.

    • The read form fails deterministically (16/16).
    • The count(*) and CREATE forms fail nondeterministically (4–7 of 8–12 runs on the same binary), which points at hash or iteration order inside the pushdown rule.
    • It already fails at 0f5bf2227 (2026-07-31), the oldest commit that compiles after the crate rename, so it has likely failed since the DataFusion 53 adoption. No GraphForge commit introduced it.

    Fix in progress on fix/2084-unwind-inline-map-patterns: project every non-column join key into a named column on its input before the join, so no join key is a field-extraction expression. Both DataFusion rules stay enabled. The tests must hold under the nondeterminism, so each form is repeated or the absence of a get_field join key is asserted.

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 workingplannerChanges to query planner

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions