Skip to content

Cypher MATCH after WITH rejects re-binding a carried secondary alias as a node variable in trailing MATCH #1341

@lmeyerov

Description

@lmeyerov

Summary

Cypher queries that carry a secondary alias through a WITH and then bind it as a node variable in a trailing MATCH are rejected by the GFQL lowering. This blocks the LDBC SNB IC1 shortestPath shape and similar re-entry patterns.

Repro (minimal, fails on master 41d865ac9)

MATCH (p:Person {id: $pid}), (friend:Person)
WHERE NOT p = friend
WITH p, friend
MATCH path = shortestPath((p)-[:KNOWS*1..3]-(friend))
RETURN friend.id AS friendId, length(path) AS dist

Expected vs observed

  • Expected: shortestPath is computed with friend already constrained from the prefix WITH.
  • Observed: GFQLValidationError: [unsupported-cypher-query] Cypher MATCH after WITH does not yet support re-binding a carried secondary alias as a node variable in the trailing MATCH | field: match | value: ['friend']

Source

  • Guard: graphistry/compute/gfql/cypher/lowering.py:7181
  • Asserting test: graphistry/tests/compute/gfql/cypher/test_lowering.py:9082 (pytest.raises(... match="re-binding a carried secondary alias"))

Benchmark evidence

  • pyg-bench artifact: results/runs/dgx-spark-ic1-conformance-2026-04-05/probe-results.json
  • LDBC SNB lane: interactive-complex-1 / named-shortest-friends
  • Probe semantic_scope: adapter_shortest_path_join_workaround — adapter currently splits this into a workaround pass because the direct shape is rejected here.
  • Official query at third_party/ldbc_snb_interactive_v1_impls/cypher/queries/interactive-complex-1.cypher uses exactly this WITH p, friend MATCH path = shortestPath((p)-[:KNOWS*1..3]-(friend)) shape.

Acceptance criteria

  • The minimal repro above succeeds end-to-end with a row per (p, friend) pair carrying the shortestPath length.
  • The secondary-alias rebinding guard at lowering.py:7181 is retired or scoped down (e.g., admit when the rebound alias is the trailing pattern endpoint of a shortestPath() / regular-pattern MATCH).
  • At least one regression test under graphistry/tests/compute/gfql/cypher/ exercises the IC1 shape directly.
  • The blocking xfail-style test asserting the guard fires can be deleted or repurposed as a positive test.

Subsystem / scope

Related

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions