Skip to content

fix(cypher): undirected MATCH wrong-answer + shortestPath/pattern-existence parser (#994, #997, #998) - #1009

Merged
lmeyerov merged 12 commits into
masterfrom
fix/cypher-994-997-998
Apr 1, 2026
Merged

lmeyerov merged 12 commits into
masterfrom
fix/cypher-994-997-998

Conversation

@lmeyerov

@lmeyerov lmeyerov commented Apr 1, 2026

Copy link
Copy Markdown
Contributor

Summary

Three fixes: one correctness bug (#994) and two parser improvements (#997, #998).

#994: Undirected MATCH wrong-answer (CORRECTNESS)

Before: MATCH (n {id: 1})-[r:KNOWS]-(friend) RETURN friend.id returned the seed (1) instead of the peer (2) when the stored edge was incoming (s=2, d=1).

After: Correctly returns peer (2) regardless of stored edge direction.

Root cause: The multi-alias bindings table (PR #986) joined on static src/dst columns, but for undirected edges the seed can be on either side. Fixed by detecting which endpoint is the seed per-row using the src alias boolean mask.

#997: shortestPath parser (PARSER)

Before: shortestPath((a)-[:R*]-(b)) → generic "Invalid Cypher query syntax"

After: Clear "shortestPath() is not yet supported" validation error

#998: Pattern existence expressions (PARSER)

Before: not((a)-[:R]-(b)), exists { ... } → generic syntax error

After: Clear "Pattern existence expressions are not yet supported" validation error

Tests (9 new)

GPU validation

All pass on pandas + cudf (dgx-spark, graphistry/test-gpu:latest).

Test plan

  • 482 lowering tests (9 new, 0 regressions)
  • GPU: pandas + cudf on dgx-spark
  • Existing multi-alias tests unaffected (24 pass)

🤖 Generated with Claude Code

lmeyerov and others added 12 commits April 1, 2026 00:38
For undirected MATCH patterns, the seed node can be on either side of
the stored edge. Detect which side is the seed per-row using the src
alias boolean mask, then compute peer_id for the undirected_peer alias.

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
)

3 new tests for the undirected MATCH bindings table fix:
- incoming edge returns peer not seed
- outgoing edge still correct (regression)
- bidirectional edges both return peer

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
…fast (#997, #998)

- shortestPath((a)-[:R*]-(b)) and allShortestPaths() now parse and
  raise GFQLValidationError("not yet supported") instead of
  GFQLSyntaxError("Invalid Cypher query syntax")
- not((a)-[:R]-(b)), exists { ... }, not exists { ... } pattern
  existence expressions now detected pre-parse and raise clear
  GFQLValidationError instead of generic syntax error

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
6 new tests: 3 for shortestPath/allShortestPaths rejection,
3 for pattern existence expression rejection.
Changelog updated with #994 fix + #997/#998 parser improvements.

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
Add 4 tests: undirected with multiple edges to same nodes,
undirected star graph with multiple peers, undirected self-loop,
and pattern existence in WHERE clause.

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
Superseded by _serialize_binding_ops + orient_edges path from #1008.
The binding_ops code path correctly handles undirected edges by
doubling them (fwd + rev) in EdgeSemantics.orient_edges.

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
…dpoints path

The alias_endpoints code path in _gfql_bindings_row_table is not called
from the Cypher lowering (which uses binding_ops + orient_edges instead).
The undirected seed/peer detection was added for #994 but never wired up.
Revert to the simpler src/dst join that matches the actual usage.

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
The fix uses orient_edges (both-direction doubling), not the removed
alias_endpoints seed/peer detection approach.

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
Covers 992f2fc fix where ParameterRef in LIMIT clause would crash
_literal_limit_value. Verifies WITH...ORDER BY...LIMIT $n...MATCH
reentry is properly rejected with a clear validation error.

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant