Repository navigation
Skip swapping join sides with join_any_take_last_row - #112458
Conversation
…ted results when settings are not respected
|
Workflow [PR], commit [631f060] Summary: ✅
AI ReviewSummaryThis PR disables join-side swapping for Findings
Final VerdictChanges requested. Preserve the prepared-lookup right-side invariant in the optimizer and pin the regression test so CI actually covers the fixed path. |
| CREATE TABLE t_small (k UInt32) ENGINE = MergeTree ORDER BY k; | ||
| INSERT INTO t_small VALUES (1); | ||
|
|
||
| -- default (query_plan_join_swap_table = 'auto'): returns 2 — WRONG |
There was a problem hiding this comment.
This regression can still pass without exercising the swap path. clickhouse-test randomizes both query_plan_optimize_join_order_limit (including 0) and query_plan_join_swap_table for unpinned tests. When the limit comes in as 0, optimizeJoinLogicalImpl returns before chooseJoinOrder, so even the 'true' query never reaches the forced-swap code; when query_plan_join_swap_table is randomized to 'false', the first query is no longer the default-'auto' case either. Please pin the same prerequisites as 03593_any_join_swap_tables here: at least query_plan_optimize_join_order_limit = 10 and an explicit query_plan_join_swap_table = 'auto' for the first query (and ideally query_plan_optimize_join_order_randomize = 0 too).
| && (!MergeJoin::isSupported(join_operator.kind, join_operator.strictness) | ||
| || !MergeJoin::isSupported(reverseJoinKind(join_operator.kind), join_operator.strictness)); | ||
| const bool suitable_swap_only_join = isSwapOnlyJoinStrictness(join_operator.strictness) && !should_worry_about_partial_merge_join; | ||
| bool skip_flip_any_join = join_settings.join_any_take_last_row && join_operator.strictness == JoinStrictness::Any; |
There was a problem hiding this comment.
This also suppresses the flip when has_prepared_storage_at_left is the reason we were flipping, not just the size-based ANY swap. Today that forced flip is what keeps JoinStepLogicalLookup on the right child; the rest of the pipeline still assumes that shape (buildPhysicalJoinImpl, joinRuntimeFilter, splitFilter, filterPushDown, calculateHashTableCacheKeys, findParallelReplicasQuery all inspect children.back() / children[1] as the lookup side).
With join_any_take_last_row = 1, a reordered multi-join involving a dictionary / StorageJoin can now leave the lookup on the left, so the prepared storage is silently dropped and later passes run on a plan shape they do not support. Please keep the forced has_prepared_storage_at_left normalization and only disable the size-based swap for ANY.
LLVM Coverage Report
Changed lines: Changed C/C++ lines covered: 9/9 (100.00%) · Uncovered code |
|
@groeneai tag someone from the ClickHouse team to review |
|
cc @davenger @antaljanosbenjamin, could you review this? @davenger has done most of the recent join-order work in |
04665 is claimed by two live open PRs (ClickHouse#112846, ClickHouse#112849). The collision is silent: the filenames differ so git reports no conflict, and check_gaps_in_tests_numbers only rejects gaps of 100 or more, never collisions. 04666, 04670, 04674 and 04675 are claimed too, by ClickHouse#112816, ClickHouse#112458 and unpublished branches respectively. Co-Authored-By: Claude Fable 5 <[email protected]>
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Close #111645