Repository navigation
Fix Merges/Mutations with enabled Block Number/Offset Min-Max Index - #109281
Conversation
|
Workflow [PR], commit [2487fce] Summary: ✅
AI ReviewSummaryThis PR tries to close the remaining merge and mutation gaps around part-level min-max support for PR Metadata
Findings
Final Verdict |
…nto enable_virtual_columns_minmax_index
This reverts commit 2f57bfc.
| } | ||
|
|
||
| const bool has_block_columns = enabledBlockNumberColumn(global_ctx) && enabledBlockOffsetColumn(global_ctx); | ||
| global_ctx->minmax_idx_columns = MergeTreeData::getMinMaxColumns(global_ctx->metadata_snapshot->getPartitionKey(), global_ctx->data_settings, has_block_columns ? MergeTreePartMinMaxIndexColumns::WITH_BLOCK_NUMBER_OFFSET : MergeTreePartMinMaxIndexColumns::PARTITION_KEY_ONLY); |
There was a problem hiding this comment.
parent_part is not a good proxy for "this merge cannot have block-column minmax". Commit-order projections already persist _block_number / _block_offset as ordinary projection columns (ProjectionIndexCommitOrder::fillProjectionDescription appends them to the projection schema), so with part_minmax_index_columns = 'with_block_number_offset' they still need minmax__block_number / minmax__block_offset on projection-part merges. With the new enabledBlock*Column check both flags become false for every projection merge, so merged commit-order projection parts are now capped to partition_key_only and lose pruning on those columns. Please key this off the actual projection-part schema / new-part columns instead of parent_part.
| { | ||
| const auto data_settings = part->storage.getSettings(); | ||
|
|
||
| if ((*data_settings)[MergeTreeSetting::enable_block_number_column] && !part_columns.has(BlockNumberColumn::name)) |
There was a problem hiding this comment.
Appending READ_COLUMN here fixes full rewrites, but it still leaves the wide/full partial-mutation path short of the advertised min-max behavior. Commands like MATERIALIZE INDEX, MATERIALIZE STATISTICS, and MATERIALIZE PROJECTION will now materialize _block_number / _block_offset on old parts, yet they still run through MutateSomePartColumnsTask; that path hardlinks the old minmax_*.idx set and MergedColumnOnlyOutputStream never writes new part-level min-max files. The mutated part ends up containing the block columns but still lacks minmax__block_number / minmax__block_offset, so part_minmax_index_columns = 'with_block_number_offset' remains ineffective until some later full rewrite. Either force these cases onto the full-rewrite path or teach the partial writer to rebuild/store min-max too.
LLVM Coverage Report
Changed lines: Changed C/C++ lines covered: 30/30 (100.00%) · Uncovered code |
…ber/Offset Min-Max Index
Backport #109281 to 26.7: Fix Merges/Mutations with enabled Block Number/Offset Min-Max Index
|
Hi @Michicosun @alesapin — a couple of suggestions to make this PR easier for reviewers and the changelog reader. Description (currently
Ignore this if the current title/body is intentional. |
|
Hi @Michicosun @alesapin — while reviewing this PR I found the following:
Could you review the test PR and add the |
…s during mutations Setting part_minmax_index_columns = 'with_block_number_offset' put _block_number and _block_offset into the per-part minmax index, but the mutation read pipeline did not materialize them, so any mutation that rewrites a part failed with Code: 341 ... Not found column or subcolumn _block_number in block. (NOT_FOUND_COLUMN_IN_BLOCK) The engine side was fixed in ClickHouse#109281, which made mutations materialize both columns. That PR covers merges and ALTER TABLE ... REWRITE PARTS in 04501_mutation_materialize_block_number_offset; this test pins the interpreter-driven mutation shapes that were reported and were not covered: ALTER UPDATE (the shape in the issue), RENAME COLUMN, DROP COLUMN and DELETE. Besides checking the mutations succeed, the test asserts the resulting minmax ranges: a rewritten part keeps (1,1) / (0,8), and DELETE narrows the _block_offset range to (1,8). Verified failing before ClickHouse#109281 and passing after it. Closes: ClickHouse#106780
Cherry-pick of #109281 "Fix Merges/Mutations with enabled Block Number/Offset Min-Max Index" to 26.6. Conflicts were resolved keeping the 26.6 base text and applying only the change of #109281 (pin `enable_block_number_column` / `enable_block_offset_column` to 0): - `02864_statistics_usage.sql`: 26.6 has no `default_compression_codec = 'LZ4'` pin, that comes from an unrelated master-only change. - `03706_statistics_preserve_checksums_on_mutations.sh`: 26.6 uses the `minmax` statistics type where master uses `basic`. Original pull-request #109281 Cherry-pick pull-request #112324 Co-Authored-By: Claude Fable 5 <[email protected]>
…ber/Offset Min-Max Index
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
This patch fixes the remaining problems needed for part-level min-max index for
_block_numberand_block_offsetcolumns.Version info
26.7.2.33