Repository navigation
fix(planner): match a reused relationship variable as the same edge - #83
Merged
Merged
Conversation
Two single-hop relationships of the same type in one MATCH could bind the same edge. Add a filter that their endpoints differ, naming anonymous endpoints so they can be compared. Fixes #59
Writing a bound relationship variable again, as in (a)-[r:KNOWS]->(b), (c)-[r]->(d), left the second part unplanned or failed on duplicate columns. Plan it as a join or filter on r's endpoint columns, taking an omitted type from the first binding. Fixes #58
Deploying lance-csr with
|
| Latest commit: |
6ad762f
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://3b96f91f.lance-csr.pages.dev |
| Branch Preview URL: | https://fix-shared-relationship-vari.lance-csr.pages.dev |
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.
Why
A relationship variable written a second time in a query should match that same relationship. Instead, the second occurrence was mishandled:
MATCH (a)-[r:KNOWS]->(b), (c)-[r]->(d) RETURN a.name... RETURN c.name, d.named__nameMATCH (a)-[r:KNOWS]->(b), (c)-[r:KNOWS]->(d) ...r__srcAn untyped
[r]was planned as a no-op, so its endpoints were never bound. A typed one scanned the relationship again under the same name. The issue named a cross join as the cause, but the cross join only connects the second part's start node, as for any pattern that starts from an unbound node.Fixes #58. Builds on #82 (#59), which has merged; this PR now targets
mainand its diff shows only this change.What changed
MATCH, in a laterMATCH, and afterWITH r.[r {w: 10}]apply to the bound relationship.MATCHit now raises an error.Known limits, marked as a
shortcut:in the code and in the guide:Validation
cargo test --workspace: all pass, including a new integration test where both the type and the endpoint labels come from the first binding.cargo clippy --workspace --all-targets -- -D warningsandcargo fmt --all: clean.make testinpython/: 1619 passed. New cases cover each direction, a reuse in a laterMATCH, a reversed bound reuse, inline properties, relationship properties and the variable-length error, withuse_csroff and on.make lint,zensical build --strictandtypos: clean.Benchmarks
The benchmark harness from CONTRIBUTING.md was run against this PR's head (
9dae1c8, which includes #82) andmain, in both suites and both modes. Every run passed every expected-answer check. None of the 44 benchmark queries reuses a relationship variable, so this PR's code path isn't reached; the type pass runs on every query, but it only walks the pattern list. The results, every query and the cost of #82's filter on IC8 and IC14 are in #82's description.main(geometric mean)memorylazymemorylazy🤖 Generated with Claude Code