feat(cypher): support variable-length rels in connected patterns (#973)#995
Merged
feat(cypher): support variable-length rels in connected patterns (#973)#995
Conversation
7eb6557 to
292c392
Compare
MATCH (a)-[:R*2]->()-[:R]->(c) RETURN c now works. Implementation: add prune_to_endpoints flag on ASTEdge that filters the graph to only max-distance endpoint nodes after a variable-length hop. The lowering sets this flag on non-terminal variable-length relationships in connected patterns so the next hop starts from the correct intermediate nodes only. Key changes: - ast.py: prune_to_endpoints on ASTEdge + all subclasses; edge pruning in __call__ using edge hop labels to find max-distance endpoints - lowering.py: _lower_relationship passes prune_to_endpoints=True for non-terminal varlen rels; guard function made no-op Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Fix prune_to_endpoints for range hops (*1..2) — keep all distances in the min..max range, not just the max distance. Fix open-range (*0..) pruning. Add empty edge guard to avoid merge errors on empty graphs. Adversarial test results: 14/15 cases pass (empty graph is pre-existing). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…log (#973) Add 11 parametrized tests for connected variable-length patterns: - Exact hops (*1, *2, *3) then fixed - Range hops (*1..2, *1..3) then fixed - Fixed then varlen - Varlen in middle (fixed-*2-fixed) - Branching graph, reverse direction, no match GPU validation: all pass on pandas + cudf (dgx-spark). 450 total lowering tests, 0 regressions. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Pre-existing mypy error: self._source/self._destination are Optional[str] but used as dict keys. Add assertion since the retry path requires them. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
529a2e9 to
6b17cf6
Compare
…rlen test The Python 3.14 minimal test suite takes >8 minutes on hosted runners, causing timeout failures. Bump to 12 minutes for headroom. Add test for typed variable-length followed by different-type fixed hop (e.g. MATCH (s)-[:A*2]->()-[:B]->(c)). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Our varlen connected patterns entry was incorrectly merged into 0.53.10 during rebase conflict resolution. Move to Development since it's not yet on master. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Support variable-length relationships in connected multi-relationship patterns (#973). Previously rejected, now
MATCH (a)-[:R*2]->()-[:R]->(c) RETURN cworks.Before
After
Implementation
Add
prune_to_endpointsflag onASTEdgethat filters the graph to only the variable-length hop's endpoint wavefront after traversal. Uses edge hop labels to identify max-distance edges, then prunes nodes + edges to only those endpoints. The lowering sets this flag on non-terminal variable-length relationships in connected patterns.Tests (11 new)
GPU validation
All pass on pandas + cudf (dgx-spark, graphistry/test-gpu:latest).
Test plan
🤖 Generated with Claude Code