Repository navigation
Iceberg bucket split by split offsets - #125636
Conversation
With `cluster_table_function_split_granularity = 'bucket'` the initiator read the footer of every file to split it into row groups. When the size of a file and the offsets of its row groups are known from the table metadata (Iceberg `file_size_in_bytes` and `split_offsets`), the file is now cut into byte ranges on these offsets without reading it, and a replica reads the row groups whose middle falls into its range. The byte range is sent in the new cluster processing protocol version 12. Files without `split_offsets` are split as before. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The number of row groups of a data file depends on the block sizes of the insert, so the test checks that files were split rather than the exact number of tasks. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Workflow [PR], commit [d9b99e2] Summary: ✅
AI ReviewSummaryThe PR adds optional Iceberg bucket splitting using manifest Consumers of the new bucket representation traced in this review:
PR Metadata💡
Missing context / blind spots
Findings
Final Verdict
|
The writing of `split_offsets` by ClickHouse goes in a separate pull request, so the stateless test, which relied on it, is replaced by an integration test on a file written by Spark, which always records `split_offsets`. The file is read through `icebergS3Cluster` with `bucket` granularity, the result must be the same as without the cluster, and the tasks must be byte ranges. Co-Authored-By: Claude Opus 5.5 <[email protected]>
`readMinMaxFromStatistics` came from master with the old `std::optional<std::unordered_set<UInt64>>` row group filter, which no longer compiles after this PR replaced it with `RowGroupSelection`. Also respect the byte-range split when reading min/max from statistics. CI report: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=125636&sha=77c8316d2fc0b4ac32fa6155a606b02523a4dda1&name_0=PR&name_1=Build%20%28arm_tidy%2C%204%2F4%29 PR: #125636 Co-Authored-By: Claude Opus 5.5 <[email protected]>
`ParquetFileBucketInfo` is copied, and the implicit copy constructor of `FileBucketInfo` is deprecated because of its user-declared destructor (`-Wdeprecated-copy-with-dtor` in the clang-tidy build). CI report: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=125636&sha=77c8316d2fc0b4ac32fa6155a606b02523a4dda1&name_0=PR&name_1=Build%20%28arm_tidy%2C%202%2F4%29 PR: #125636 Co-Authored-By: Claude Opus 5.5 <[email protected]>
Byte range buckets cannot be sent to workers on an older cluster processing protocol, so splitting by `split_offsets` by default made `bucket` reads fail with `UNKNOWN_PROTOCOL` during rolling upgrades. Add `cluster_table_function_split_by_split_offsets` (disabled by default) to enable it once all servers are upgraded, and mention it in the exception message. On a hit in the query condition cache, split by the footer instead, so that `filterByMatchingRowGroups` can drop buckets without matching row groups. PR: #125636 Co-Authored-By: Claude Opus 5.5 <[email protected]>
The ranges are cut on `split_offsets`, which writers set to the row group starts, so assigning a row group by its start is enough and is simpler than the midpoint rule. Compute the start like `getStartingPos` in parquet-mr, from the first column chunk, so it matches `split_offsets` and does not depend on `file_offset`; throw `INCORRECT_DATA` on invalid offsets instead of falling back to 0. PR: #125636 Co-Authored-By: Claude Opus 5.5 <[email protected]>
Replace the midpoint-based assignment in `splitByByteRanges` with the same greedy accumulation as `splitToBuckets`: a row group joins the current bucket while the bucket stays within `cluster_table_function_buckets_batch_size`. PR: #125636 Co-Authored-By: Claude Opus 5.5 <[email protected]>
| if (protocol_version >= DBMS_CLUSTER_PROCESSING_PROTOCOL_VERSION_WITH_FILE_BUCKET_BYTE_RANGE) | ||
| { | ||
| writeVarUInt(byte_range.has_value() ? 1 : 0, buffer); | ||
| if (byte_range.has_value()) | ||
| { | ||
| writeVarUInt(byte_range->first, buffer); | ||
| writeVarUInt(byte_range->second, buffer); |
There was a problem hiding this comment.
Connection::sendClusterFunctionReadTaskResponse sends this payload as a native ReadTaskResponse. Cluster protocol version 12 now appends a VarUInt presence flag and, when present, the byte offset and length. Even with cluster_table_function_split_by_split_offsets disabled, a version-12 Parquet bucket gains the zero presence flag, so this changes the wire layout independently of enabling the optimization.
Please update the matching native-protocol specification in this change to document version 12, the gated fields and their ordering, and the restriction on older workers. The English specification currently lives at docs/resources/develop-contribute/native-protocol/protocol.mdx; no protocol documentation is included in this diff.
…t-by-split-offsets Keep writing `split_offsets` from `master`, which an earlier revert in this branch would have dropped. Move `DBMS_CLUSTER_PROCESSING_PROTOCOL_VERSION_WITH_FILE_BUCKET_BYTE_RANGE` to 14 after the versions taken in `master`. Select the row groups of a byte range in `Reader::selectRowGroups`, as column chunks are now parsed lazily. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…in the settings history The setting is new in this PR, which was not in `26.10`, so the style check `settings_changes_history` requires a `26.11` record. https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=125636&sha=16d4f481541e69792be0d77bbbc2ab89f5e48a5c&name_0=PR&name_1=Style%20check #125636 Co-Authored-By: Claude Opus 5.5 <[email protected]>
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
The official master build is compiled with Object file sizes24 object files changed (+63.07 KiB total), 0 added.
719 more object files are built by the master warmup baseline only (it builds every object-file target, a pull request build only Compile time of recompiled translation units477 translation units recompiled, 4200 s compile time in total, 477 of them have a recent master baseline. Median compile-time ratio to the baselines is ×0.94 (machine-speed difference or a change affecting every TU); per-TU deltas below are relative to that ratio. |
|
we'd need to update |
- Make `count`-only reads of a Parquet bucket count only the selected row groups instead of the whole file. - Do not read or write the per-file row count cache for bucket reads: a bucket count is not the file count. - Let the last byte-range bucket extend to the end of the file, so a `file_size_in_bytes` smaller than the real size in the manifest does not lose the last row groups. - Qualify the Spark `files` metadata table with the namespace in the test, and add a standalone `SELECT count()` assertion. #125636 Co-Authored-By: Claude Opus 5.5 <[email protected]>
…t-by-split-offsets # Conflicts: # src/Core/ProtocolDefines.h
…:selectRowGroups` https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=125636&sha=d8c3c066928108bf7f5c4ee735c55fb38d465f6b&name_0=PR&name_1=Build%20%28arm_tidy%2C%204%2F4%29 #125636 Co-Authored-By: Claude Opus 5.5 <[email protected]>
… test Iceberg returns `split_offsets` of a data file only if the last offset is below the size of the file, so a query of the `files` metadata table that does not project `file_size_in_bytes` reads them as `NULL`, with Spark 4.0 and Iceberg 1.11.0 of the integration test image. The test selected only `split_offsets`, so it failed on its own precondition before it reached ClickHouse; `test_writes_split_offsets.py` selects both. CI report: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=125636&sha=7174a395852497b4a7565b36c26cc1c082e91a2e&name_0=PR&name_1=Integration%20tests%20%28amd_asan_ubsan%2C%20db%20disk%2C%20targeted%29 PR: #125636 Co-Authored-By: Claude Opus 5.5 <[email protected]>
A bucket selects either row group ids or a byte range, never both: byte range buckets are only made without a `QueryConditionCache` entry, and a worker does not consult the cache for a bucket it received. So `filterByMatchingRowGroups` goes back to building the bucket from row group ids, and throws on a byte range bucket. #125636 Co-Authored-By: Claude Opus 5.5 <[email protected]>
arsenmuk
left a comment
There was a problem hiding this comment.
lgtm - still need to update protocol.mdx #125636 (comment)
…tting-improvements Most of this branch landed through separate PRs: #125611 #125615 #125636 Their versions are kept. Bucket splitting by `min_buckets` is applied on top of the greedy splitter of master, the weight of a byte range bucket is capped by the file size, byte ranges are gated by `cluster_table_function_split_by_split_offsets`, and the duplicate test of the filter pushdown is removed. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…-parallel-read Resolve conflicts with #125636 (`RowGroupSelection` as a `std::variant`, byte-range buckets): `ReadManager::init` takes a `RowGroupSelection` together with `other_row_groups_are_read_by_other_readers`, and `IBucketSplitter` has both `splitForParallelReading` and `splitByByteRanges`. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Version 16 sends the injection sites of every Iceberg identity partition value, so the native protocol spec has to name it (.claude/CLAUDE.md requires a spec update for a protocol version bump). Version 15 (the byte range of a Parquet file bucket, ClickHouse#125636) was never added to the spec, so it is documented here as well; the spec still said 14. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Iceberg bucket split by split offsets. Do not use parquet metadata anymore - let's split file by split offsets from metadata
Workflow [PR]
Sync PR [sync-upstream/pr/125636]
Version info
26.11.1.1357-master(included in26.11and later)