fix(wren-core): preserve composite-key predicates in relationship joins#2323
fix(wren-core): preserve composite-key predicates in relationship joins#2323goldmedal wants to merge 2 commits into
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
WalkthroughParses SQL join condition strings into ordered column-equality pairs, updates relation chain logic to rebase and AND-conjoin all equality predicates for composite-key relationships, and adds an end-to-end test validating composite join predicates appear in generated SQL. ChangesComposite Key Join Condition Support
🎯 3 (Moderate) | ⏱️ ~20 minutes
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Relationship `condition` strings such as `a.x = b.x AND a.y = b.y` parsed fine but were collapsed by `RelationChain::plan` into a single equality — the planner extracted all identifiers and then used only the first two, silently dropping any further conjuncts. The TPCH partsupp fixture already carried a `// composite primary key` TODO noting this gap. Add `collect_join_keys`, which parses the condition expression and returns equality pairs in AST order, rejecting non-equality / disjunction shapes with a clear error. The relation_chain planner now rebases each column to the right alias as before and ANDs the per-pair equalities into the final join predicate. Covered by new unit tests for the parser and an end-to-end test asserting both predicates appear in the generated SQL for a composite-key relationship. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
6d3362b to
1cba5ef
Compare
Replace the substring assertions in test_composite_key_relationship with an inline assert_snapshot! over the full transformed SQL, matching the style of other relationship/calculation tests in this module. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Summary
RelationChain::planextracted all identifiers from a relationshipconditionand then used only the first two — soa.x = b.x AND a.y = b.ylost the second equality, breaking composite-key joins. The TPCH partsupp fixture in this repo already carries a TODO noting the gap (// ps_partkey and ps_suppkey should be composite primary key).collect_join_keys(new helper inmdl/utils.rs) that parses the condition expression and returns equality pairs in AST order, rejecting non-equality / disjunction / non-column shapes with a clear error.relation_chain.rsnow rebases each column to the right alias (same logic as before) and ANDs the per-pair equalities into the final join predicate.conditionstrings, which were previously expressible in MDL but silently truncated.Test plan
cargo fmt --allcargo clippy --all-targets --all-features -- -D warningsRUST_MIN_STACK=8388608 cargo test --lib --tests --bins --release— 133 passed (8 new helper tests + 1 new e2e composite-key test)view.slt,model.slt,tpch/tpch.slt,type.slt) all pass🤖 Generated with Claude Code
Summary by CodeRabbit
New Features
Bug Fixes
Tests