fix: scoping-only WITH collapse guard for chained patterns#210
Merged
fix: scoping-only WITH collapse guard for chained patterns#210
Conversation
The scoping_with_collapse analyzer was too aggressive — it collapsed WITH clauses in chained patterns (e.g., WITH a, b after WITH a), losing CTE boundaries and dropping JOINs for downstream variables. Added contains_with_clause() guard to preserve WITHs whose input subtree already contains a WithClause node. Also fixes denormalized VLP property lookup (reverse map lookup), resolves merge conflict in test_vlp_aggregation.py, fixes wrong property name in test_with_cte_node_expansion.py, and xfails two denormalized VLP tests pending full CTE wiring. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1. Exhaustive match in contains_with_clause() — replaces _ => false wildcard with explicit leaf variants (Empty, ViewScan, PageRank) and adds missing GraphNode arm. Catches future LogicalPlan variants at compile time. 2. Log message when guard prevents collapsing — aids debugging chained WITH patterns where the optimization is intentionally skipped. 3. Two new unit tests: test_collapse_preserves_outer_with_when_input_ contains_with (chained WITH guard) and test_collapse_works_when_ inner_with_already_collapsed (bottom-up semantics). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
genezhang
added a commit
that referenced
this pull request
Mar 12, 2026
Remove @pytest.mark.xfail from tests that pass after recent VLP, shortestPath, denormalized schema, and multi-type property fixes (PRs #206-#210). Affected areas: VLP aggregation, shortest paths, path variables, edge constraints, multi-type property extraction, denormalized VLP, VLP relationship return, VLP WITH comprehension, pattern matrix. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2 tasks
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
scoping_with_collapseanalyzer was too aggressive — it collapsed chained scoping-only WITH clauses (e.g.,WITH a, bafterWITH a), losing CTE materialization boundaries and dropping JOINs for downstream variables. Addedcontains_with_clause()guard to skip collapse when the input subtree already contains a WithClause.map_denormalized_property()incte_manager/mod.rsnow does reverse lookup by value when forward key lookup fails, fixing VLP CTE generation for denormalized schemas.test_vlp_aggregation.py, fixed wrong property name intest_with_cte_node_expansion.py, added xfail markers for 2 denormalized VLP tests pending full CTE wiring.Test plan
cargo test)🤖 Generated with Claude Code