Repository navigation
Add setting analyzer_compatibility_apply_final_to_all_joined_tables - #111589
Conversation
PR ClickHouse#108979 fixed FINAL on the left-most table of a JOIN leaking onto the other joined tables. The fix is result-changing for queries over ReplacingMergeTree tables with unmerged duplicate rows that relied on the old behavior, and had no compatibility gate. Put the legacy behavior under the new setting and register it in SettingsChangesHistory so that compatibility with versions before 26.7 restores the old semantics.
|
Workflow [PR], commit [fae8978] Summary: ❌
AI ReviewSummaryThis PR adds Findings❌ Blockers
Tests
Final VerdictStatus: |
| select_query_info.query = queryNodeToSelectQuery(query_tree); | ||
| select_query_info.query_tree = query_tree; | ||
| select_query_info.planner_context = planner_context; | ||
| select_query_info.apply_query_level_final_if_no_modifiers |
There was a problem hiding this comment.
This only fixes the planner-local path. When the query is lowered to a logical plan (build_logical_plan, e.g. serialize_query_plan=1 distributed queries and the remote side of parallel replicas), the new bit is not serialized: ReadFromTableStep carries only TableExpressionModifiers, and resolveStorages.cpp reconstructs the non-left JOIN tables with {hasFinal = false} and no query_tree. At that point SelectQueryInfo::isFinal returns false before it can fall back to the left table's FINAL, so compatibility = '26.6' still gives 26.7 semantics on those paths. Can we either materialize hasFinal = true onto every affected joined table before emitting the logical-plan read steps, or serialize this compatibility flag alongside them?
… in 26.4 Move the settings-changes-history entry from 26.7 to 26.6 (true -> false), matching the planned backport of the fix with the setting defaulting to false on the 26.6 release line. Add an introduction entry to 26.4 (true -> true) for backports to 26.4 and 26.5, where the setting will default to true and preserve the old behavior. Adjust the test to use compatibility = '26.5' since 26.6 now maps to the fixed behavior.
|
Updated per backport plan: moved the settings-history entry from |
The check requires any setting that is new relative to the last released version to appear in a history block newer than 26.6. Add a no-op (false -> false) entry under 26.7; the behavior flip stays recorded under 26.6 and the backport introduction under 26.4, so compatibility resolution is unchanged.
…e_nullable_nothing from master
LLVM Coverage Report
Changed lines: Changed C/C++ lines covered: 40/40 (100.00%) · Uncovered code |
8aab148
Cherry pick #111589 to 26.6: Add setting `analyzer_compatibility_apply_final_to_all_joined_tables`
…inal_to_all_joined_tables`
Backport #111589 to 26.6: Add setting `analyzer_compatibility_apply_final_to_all_joined_tables`
The automated backport of #111589 to 26.7 imported master's newest `addSettingsChanges(settings_changes_history, "26.8", {...})` block, which `origin/26.7` does not have. Four of its five settings do not exist in the 26.7 tree at all, so `SettingsImpl::applyCompatibilitySetting` walks the history newest-first, calls `getTier()` for every entry above the requested version and reaches `throwSettingNotFound`, making every `compatibility` value below 26.8 fail with `UNKNOWN_SETTING`. Only the two entries the backport actually needs are kept: the 26.6 behaviour flip and the 26.4 introduction. This matches the already-merged 26.6 sibling backport #111987 byte for byte. Co-Authored-By: Claude Fable 5 <[email protected]>
Backport #111589 to 26.7: Add setting `analyzer_compatibility_apply_final_to_all_joined_tables`
…-setting Add setting `analyzer_compatibility_apply_final_to_all_joined_tables`
Related: #108979
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
analyzer_compatibility_apply_final_to_all_joined_tablesthat restores the old behavior, where theFINALmodifier on the left-most table of a JOIN was also applied to the other joined tables. The setting is registered in the settings changes history, socompatibilitywith versions before 26.6 restores the old semantics automatically.#108979 fixed
FINALon one table of a JOIN leaking onto the other joined tables. While the new behavior matches the documented semantics (FINALis a per-table-reference modifier), the fix is result-changing for queries that (perhaps unknowingly) relied on the leak: joining aFINALtable to anotherReplacingMergeTreethat has unmerged duplicate versions now multiplies the matching rows instead of deduplicating them, e.g.and there was no way to get the old results back other than rewriting the query (adding
FINALto every joined table — which remains the recommended fix).This PR puts the legacy behavior under the new setting
analyzer_compatibility_apply_final_to_all_joined_tables(defaultfalse= the fixed behavior) by gating the query-level-FINALfallback inSelectQueryInfo::isFinal.The settings changes history is staged for backports of this setting to the release branches:
true26.4: true -> true(introduction)truefalse26.6: true -> falsefalseso
SET compatibility = '26.5'(or earlier) restores the old semantics without query changes, and the 26.4/26.5 release lines keep the old behavior by default.Version info
26.8.1.167(included in26.8and later)26.7.2.28,26.6.2.119