Skip to content

feat(cypher): support multi-alias carry through WITH before MATCH re-entry (#1071)#1247

Merged
lmeyerov merged 4 commits intomasterfrom
issue-1071-with-multi-alias-carry
May 3, 2026
Merged

feat(cypher): support multi-alias carry through WITH before MATCH re-entry (#1071)#1247
lmeyerov merged 4 commits intomasterfrom
issue-1071-with-multi-alias-carry

Conversation

@lmeyerov
Copy link
Copy Markdown
Contributor

@lmeyerov lmeyerov commented May 2, 2026

Summary

  • Lifts the residual constraint that the prefix WITH before a Cypher MATCH re-entry must project exactly one whole-row node alias. LDBC SNB IC1 and any pattern carrying two or more node bindings (WITH p, friend, ...) now compile and execute locally.
  • Implementation: _compile_bounded_reentry_query pre-rewrites the prefix WITH. The trailing-MATCH primary alias remains the sole whole-row carry; secondary aliases are demoted to scalar property carries via synthesized S.X AS __cypher_reentry_<S>_<X>__ items, with downstream S.X references rewritten to bare hidden identifiers that compose with the existing single-alias machinery (Cypher/GFQL: multi-alias WITH prefix projection for bounded reentry #1047 / fix(cypher): support multi-row scalar prefix in MATCH re-entry (#1047) #1068).
  • Out of scope (precise unsupported errors): returning a secondary alias as whole-row (RETURN s); re-binding a secondary alias as a node variable in the trailing MATCH.

Closes #1071.

Test plan

  • python -m pytest graphistry/tests/compute/gfql/cypher/ — 1097 passed, 66 skipped, 15 xfailed
  • ./bin/typecheck.sh — clean (229 source files)
  • ./bin/lint.sh — clean
  • New regression tests:
    • test_string_cypher_executes_ic1_shaped_multi_alias_with_match_reentry — IC1 shape with p.firstName carry
    • test_string_cypher_executes_three_alias_with_match_reentry — 3-alias carry
    • test_string_cypher_with_match_reentry_multi_whole_row_alias_unreferenced_secondary
    • test_string_cypher_with_match_reentry_multi_whole_row_alias_property_carry
    • test_string_cypher_failfast_rejects_with_match_reentry_secondary_whole_row_return
  • Retargeted prior failfast tests that locked the old single-alias rejection:
    • test_issue_1026_multi_alias_with_optional_match_carries_secondary_property (was _rejects_cleanly)
    • test_string_cypher_with_match_reentry_multi_whole_row_alias_unreferenced_secondary (was _failfast_rejects_with_match_reentry_multiple_whole_row_aliases_with_carried_scalars)

🤖 Generated with Claude Code

lmeyerov and others added 4 commits May 1, 2026 17:57
…entry (#1071)

Pre-rewrite the prefix WITH stage in _compile_bounded_reentry_query so
secondary whole-row aliases are demoted to scalar property carries
(S.X AS __cypher_reentry_<S>_<X>__) and downstream S.X references compose
with the existing single-whole-row machinery (#1047/#1068). RETURN of a
secondary whole-row alias, and re-binding a secondary alias as a node
variable in the trailing MATCH, remain unsupported with precise errors.

Closes #1071.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…#1071)

Closes review gaps surfaced by /review on PR #1247:
- assert the secondary-alias rebinding guardrail (re-binding a carried
  secondary alias as a node variable in the trailing MATCH)
- add a cuDF parity test for the property-carry path

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…as rewrite (#1071)

Wave 2 review follow-ups on PR #1247:
- Upgrade the IC1-shape regression test to use the actual variable-length
  [:KNOWS*1..3] path the LDBC SNB IC1 query specifies, exercising both
  1-hop and 2-hop secondary-alias carry.
- Add a regression test that locks the tree-shape (OR) trailing WHERE
  rewrite of a secondary alias property reference; verifies the demoter
  composes correctly with _rewrite_where_clause_and_resync.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…hs (#1071)

Wave 3 review follow-ups on PR #1247:
- Lock the double-prefix collision-resistance: a user-named carried scalar
  (b.id AS a_id) and a demoted secondary property ref (a.id) both target
  output 'a_id'/'__cypher_reentry_a_id__' in the prefix WITH; the outer
  _reentry_hidden_column_name wrap keeps the in-table columns distinct,
  so values flow correctly to RETURN. Defense-in-depth against future
  changes to the carry naming scheme.
- Lock the inline node-pattern property map rewrite path: a secondary
  alias property reference inside a node pattern's property map
  (MATCH (c {tag: a.tag})) is correctly rewritten via
  _rewrite_reentry_match_clause's pattern-element walk.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@lmeyerov lmeyerov merged commit d31e21a into master May 3, 2026
261 of 263 checks passed
@lmeyerov lmeyerov deleted the issue-1071-with-multi-alias-carry branch May 3, 2026 02:43
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.

Cypher: WITH before MATCH re-entry restricts projection to single whole-row alias (blocks IC1)

1 participant