Repository navigation
Use partition statistics from manifest list for pruning - #115817
Conversation
|
Workflow [PR], commit [cd9a0ea] Summary: ✅
AI ReviewSummaryAdds manifest-list partition pruning for Iceberg by caching each manifest entry's partition summaries and skipping manifests whose summaries cannot satisfy the query filter, behind PR Metadata
Findings
Tests
Final Verdict
LLVM Coverage Report |
9e977fa to
f0cd374
Compare
d440fb9 to
c107b49
Compare
|
📊 Cloud Performance Report ✅ AI verdict: no significant changes detected. K_source=6 K_base=30 flagged=0/65 clickbench🟢 No significant changes tpch_adapted_1_official🟢 No significant changes Debug info
|
Resolve the conflicts with the Iceberg changes that landed on `master` meanwhile, and fix the two CI failures of the pull request: - `master` replaced the prefetching `SingleThreadIcebergKeysIterator` with the concurrent `DataFileEntriesStream`, so the manifest list pruning is re-applied there: the stream takes a `SkipManifest` predicate, and `ManifestListPruner` is built in the stream's `prepare` callback, after `buildOrderedSetsForDAG`, because the key conditions of the pruner are built over the filter DAG. - `master` added row lineage columns to the filter DAG transformation and the manifest partition tuple arity check, so `renameFilterDagColumnsToFieldIds` and `buildPartitionKeyFromSpec` carry them over from the member function this branch extracted them from. - The binary bound decoding, which this branch moved into `IcebergFieldParseHelpers`, keeps the `compensate_rounding` flag and the overflow rejection that `master` gained in the meantime, and `ManifestFileIterator` uses that single shared implementation. - `ManifestFileCacheKey` carries both the partition summaries of this branch and `first_row_id` of `master`. Build (arm_tidy) failed with `performance-move-const-arg`: `KeyDescription` has a user-declared copy constructor and hence no move constructor, so the `std::move` of it in `ManifestListPruner` is dropped. Style check failed because `use_iceberg_manifest_list_partition_pruning` was recorded in the `26.8` block of `SettingsChangesHistory.cpp` while the current version is `26.9`; the entry is moved to the `26.9` block. CI report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=115817&sha=a23f9bd482b562de33ac5ecdbd7b555e812944e4 Related: #115817 Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
The official master build is compiled with Object file sizes31 object files changed (+223.62 KiB total), 1 added.
716 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 units78 translation units recompiled, 764 s compile time in total, 77 of them have a recent master baseline. |
Skipping a manifest through its manifest-list partition summaries also skips every data file it lists, but only `IcebergPartitionPrunedManifestFiles` was incremented, so `IcebergPartitionPrunedFiles` dropped to zero exactly when pruning got better. That is what broke `test_partition_pruning` and `test_optimize_manifest_files_decimal_partition`: both measure pruning through that counter, and both hit tables whose manifests hold a single partition each (one written by a later `INSERT`, the others produced by `OPTIMIZE ... MANIFEST`, which clusters entries by partition). The skipped manifest's `live_files_count` is now added to the file counter, which is also what keeps the counter working once ClickHouse starts writing partition summaries of its own. Manifest-list pruning is also gated on `use_iceberg_partition_pruning`, as the description of `use_iceberg_manifest_list_partition_pruning` already states. It was only checking its own setting, so a query that switched partition pruning off still had manifests skipped under it, and the reference run of the pruning tests would have counted skipped files. The test of the feature now pins both counters and the interaction with `use_iceberg_partition_pruning`.
`deserializeFieldFromBinaryRepr` hands the bound bytes to `IColumn::insertData`, which for a fixed-size column ignores the length and reads the width of the type. Iceberg stores a bound as it was written, so after an `int` -> `long` promotion of a partition column the manifest list keeps a 4-byte bound for a column that is `Int64` now, and reading it produced a garbage bound out of 4 bytes past the buffer. Under MSan that killed the server, which is how the `amd_msan` shard reported it: every `test_partition_pruning` query after `ALTER TABLE ... ALTER COLUMN tag TYPE BIGINT` failed with a network error. A bound narrower than the type is reported as absent now, so such a manifest is not pruned instead of being pruned by a bound made of uninitialized memory. Reproduced locally with the MSan build of the previous commit: the added test kills the server without this fix and passes with the bound treated as absent. CI report: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=115817&sha=5036ffab8829347b65f9eaf727b236301b416ad8&name_0=PR PR: #115817 Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
| if (!fields || fields->size() == 0) | ||
| continue; | ||
|
|
||
| auto partition_key = buildPartitionKeyFromSpec(fields, partition_schema_id_, schema_processor_, context); |
There was a problem hiding this comment.
This builds one manifest-list condition per partition_spec_id against a single partition_schema_id_, but a current snapshot can still reference manifests that were added under an older snapshot schema. In that case buildPartitionKeyFromSpec drops any source field that no longer exists in partition_schema_id_, and the arity check here disables manifest-list pruning for the whole historical spec.
A concrete case is a mixed-spec table like (region, day(ts)) after DROP PARTITION FIELD region and then DROP COLUMN region: queries on ts can still be pruned from the old manifests' summaries, but this code never builds a usable condition for that spec. Since ManifestFileCacheKey already carries added_snapshot_id and IcebergSchemaProcessor tracks snapshot_id -> schema_id, I think this needs schema-aware conditions (or at least a regression test that documents the limitation).
Manifest-list partition pruning skips a manifest by the partition summaries the manifest list carries, and reports the files it skips through `IcebergPartitionPrunedFiles`. `05045_iceberg_manifest_partition_arity` patches the `partition-spec` header of the manifests but never the manifest list, so with the new pruning on the A7 and A8 probes were answered before the patched manifest was ever read: their counters went from 0 to 1 and the arms stopped saying anything about the pruner they were written for - in particular that a partition key narrower than the tuple is not realigned onto the wrong value. Turn `use_iceberg_manifest_list_partition_pruning` off for those probes, and add A9 to pin the new behaviour instead of losing it: the manifest list prunes both tables before their patched manifests are read, and the rows that survive are still the right ones. CI report: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=115817&sha=083fda43bd9d54e6dd600ab963dced915957c53f&name_0=PR Related: #115817 Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
| [this](const ManifestFileCacheKey & manifest_list_entry) | ||
| { | ||
| if (!manifest_list_pruner | ||
| || !manifest_list_pruner->canBePruned(manifest_list_entry.partition_spec_id, manifest_list_entry.partition_summaries)) |
There was a problem hiding this comment.
use_iceberg_manifest_list_partition_pruning is only wired into data_files_stream, but next still calls ensureDeletesReady() first and decodeDeleteManifests() then walks every delete manifest unconditionally. On merge-on-read tables a partition-filtered query therefore still blocks on opening all delete manifests, even though the manifest list already carries partition_spec_id / partition_summaries for those entries and ManifestFilesPruner already applies partition pruning to delete-file entries after decode.
I think the new setting needs the same manifest-list skip on the delete-manifest path, or its contract/docs need to be narrowed to say it only affects data manifests. As written, the improvement disappears on the row-level-delete tables that also tend to accumulate the most delete manifests.
Conflict in `ManifestFileIterator.cpp`: this branch moved `deserializeDecimalBound` and `deserializeFieldFromBinaryRepr` into `IcebergFieldParseHelpers` so that `ManifestListPruning` can use them too, while master kept its own copies inline and gave `getMaterializedRowLineageRange` an extra `path_to_manifest_file` argument. Resolved by keeping master's signature, which is what the caller in this file now passes, and dropping master's inline copies of the two helpers, which would otherwise clash with the ones this file already includes from `IcebergFieldParseHelpers.h`. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
| upper = deserializeFieldFromBinaryRepr(*summary.upper_bound, type, false); | ||
| } | ||
|
|
||
| left_keys[i] = (lower.has_value() && !summary.contains_null) ? FieldRef(*lower) : FieldRef(NEGATIVE_INFINITY); |
There was a problem hiding this comment.
contains_null means the manifest may also contain NULL, but the non-null values are still bounded by lower_bound / upper_bound. Under the same NULL_LAST convention used in ManifestFilesPruner, the safe interval for a summary like {NULL, 100} is [100, +inf], not (-inf, +inf).
Widening the left edge to NEGATIVE_INFINITY here drops valid pruning for predicates below the first non-null value (WHERE p = 0, WHERE p < 50, and so on), so nullable partition columns stop benefiting from manifest-list pruning whenever a manifest mixes NULL and concrete values. Please keep the decoded lower bound when contains_null is true and only widen the upper edge to POSITIVE_INFINITY.
Antalya 26.8 - Backport of ClickHouse#114817 - Use partition statistics from manifest list for pruning- ClickHouse#115817
… NULL partition value `ManifestListPruner::canBePruned` passed the per-field partition summaries of a manifest-list entry to `KeyCondition::mayBeTrueInRange`, which treats the two key vectors as the ends of a range of tuples, and replaced the bounds of a field that contains NULL with -inf/+inf. The tuple decomposition evaluates a later field over the non-Nullable key type's universe, which excludes NULL, everywhere except next to the boundary values of the earlier fields. So on a table partitioned by `a, b`, `WHERE a = 2 AND b IS NULL` was judged impossible for a manifest with `a` in [1, 3] and a NULL `b`, and the manifest was skipped: no rows instead of the matching ones. With NULL also in `a`, no real value of `a` could pair with a NULL `b` at all (the fuzzer's shape). PyIceberg and Spark write one manifest per commit covering all its partitions, so this hits ordinary tables at default settings since 26.9 (ClickHouse#115817). Iceberg `field_summary` bounds each field independently, so the manifest's partition tuples lie in the box of the per-field ranges. Evaluate exactly that box with `KeyCondition::checkInHyperrectangle`: `[lower, upper]`, or `[lower, +inf]` when the field contains NULL (NULL sorts last, the encoding `ManifestFilesPruner` uses for a NULL partition value), or the whole universe when the bounds are missing, NaN, undecodable or inverted. For NULL-free summaries the box is inside the old tuple range, so no correct prune is lost, and the bounds of fields after the first are now used too. Found by the Data lake fuzzer (arm_release), NightlySQLancer, master 2332693, pyiceberg_rest seed 228157089. Closes ClickHouse#129913 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 manifest list contains statistics like lower_bound, upper_bound, and etc that can be used for pruning. This PR use them to prune data. Closes #104567
Workflow [PR]
Sync PR [sync-upstream/pr/115817]
Version info
26.9.1.1103(included in26.9and later)