Repository navigation
Do not derive conjuncts in outer JOIN ON - #124233
Conversation
|
Workflow [PR], commit [3a47fa4] Summary: ✅
AI ReviewSummaryThis PR fixes #124078 by tracking the preserved side while Final Verdict
LLVM Coverage ReportMeasured on commit 3a47fa4.
Changed lines: Changed C/C++ lines covered: 20/20 (100.00%) · Uncovered code |
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
The official master build is compiled with Compile time of recompiled translation units7 translation units recompiled, 12 s compile time in total, 7 of them have a recent master baseline. |
Backport #124233 to 26.9: Do not derive conjuncts in outer JOIN ON
Backport #124233 to 26.8: Do not derive conjuncts in outer JOIN ON
…e keys With `optimize_and_compare_chain`, the chain derives `expr op const` from `expr = y AND y < 2` and appends it to the `AND`. In an outer join `ON` a conjunct over the preserved side cannot be pushed down, so it stays in `ON` and `full_sorting_merge` rejects the join with `NOT_IMPLEMENTED`. ClickHouse#124233 guarded this with `getExpressionSource(expr).first`, which is `nullptr` for an expression over several table expressions, so the guard missed `a.number + b.number` over an inner join, the `firstNonDefault` key of `FULL JOIN ... USING`, and an `ARRAY JOIN` alias mixed with a column. Test every column's source against the preserved tables instead. The `ALWAYS_FALSE` branch also appended a preserved-side contradiction unguarded. A bound the guard skipped was still recorded, so a later bound on the same expression conflicted with it (`l.number < 2` skipped, then `l.number > 5` appended), and a type-impossible bound (`UInt8 > 300`) was appended on its own; with `optimize_redundant_comparisons = 0` nothing folds them and the join is rejected. Derive a preserved-side bound only when the user already wrote a conjunct on that expression: the derivation then still exposes a contradiction the next pass folds to `false`, and that `ON` already holds a preserved-side conjunct of the user's. Closes ClickHouse#125291 Co-Authored-By: Claude Opus 5.5 <[email protected]>
Closes: #124078
Related: #123796
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Fix
NOT_IMPLEMENTEDfor an outerJOINwithjoin_algorithm = 'full_sorting_merge'whenoptimize_and_compare_chainderived a condition on the preserved side of the join from theONclause.Workflow [PR]
Sync PR [sync-upstream/pr/124233]
Version info
26.10.1.2159-master(included in26.10and later)26.9.17.4,26.8.25.7