Repository navigation
Fix filling of a missing DEFAULT column with multiple PREWHERE read steps - #111795
Conversation
|
Workflow [PR], commit [dec47a2] Summary: ✅
AI ReviewSummaryThis PR fixes evaluation of missing PR Metadata
Closes: https://github.com/ClickHouse/ClickHouse/issues/111757
### Changelog entry (a [user-readable short description](https://github.com/ClickHouse/ClickHouse/blob/master/docs/changelog_entry_guidelines.md) of the changes that goes into CHANGELOG.md):
Fixes reads of `DEFAULT`-materialized columns from pre-`ALTER` parts when multi-step `PREWHERE` is used, so queries evaluate the `DEFAULT` expression instead of returning the type default.Final Verdict
|
LLVM Coverage Report
Changed lines: Changed C/C++ lines covered: 6/6 (100.00%) · Uncovered code |
|
Hi — this looks like a backport candidate for Not needed on |
…y evaluate defaults `ReadResult::additional_columns` holds the columns each PREWHERE step projects out. Since ClickHouse#111795 they are carried across all later steps, so every later step filters them again in `ReadResult::applyFilter`. Their only consumer is `MergeTreeReadersChain::evaluateMissingDefaults`, which runs only when a later reader's `fillMissingColumns` leaves a requested column unfilled: a column with a default expression, or a subcolumn whose parent is available. `mayLeaveColumnToMissingDefaults`, next to `fillMissingColumns` and built from the same `hasDefault`, is a superset of those two cases. `IMergeTreeReader::mayEvaluateMissingDefaults` applies it to the requested columns. The chain asks every reader but the first one (it has no earlier step) when it is built, once per read task, and the reader caches the answer because it is reused by the consecutive read tasks of a part: without the cache the check took 1.7% of ClickBench Q3 in the reporter's profile. Only the steps before the last reader that may evaluate defaults keep the columns. A `chassert` in `evaluateMissingDefaults` checks the superset on every default evaluation. `executePrewhereActionsAndFilterColumns` takes `keep_additional_columns` instead of `is_last_reader`, whose only use there was this decision. ClickHouse#118630 introduces the same parameter for the same decision. Found and analysed by @ snelheidai in ClickHouse#128432. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Backport #111795 to 26.3: Fix filling of a missing DEFAULT column with multiple PREWHERE read steps
…h multiple PREWHERE read steps
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Fix a DEFAULT column missing in a part being filled with the type default instead of the DEFAULT expression when the PREWHERE condition was split into multiple read steps. Closes #111757
Version info
26.8.1.678-master(included in26.8and later)