Repository navigation
Fix Iceberg manifest-list pruning skipping NULL partitions for ifNull/coalesce filters - #130158
Conversation
…/coalesce ClickHouse#129929 evaluates a partition field whose manifest-list summary contains NULL as the range [lower, +inf] (NULL sorts last). The key that range is checked against comes from buildPartitionKeyFromSpec, which strips Nullable from every source column. For a non-Nullable type ifNull, coalesce and assumeNotNull report themselves monotonic, so the +inf bound is left untransformed and e.g. [5, +inf] against the set {0} for `ifNull(b, 0) IN (0)` prunes the manifest that holds the NULL row. Build the manifest-list pruner's key with the source columns' own types (keep_nullable), the convention MergeTree's min-max index uses for a Nullable partition column. Those functions then see a range that can hold NULL and decline, while NULL-rejecting predicates keep pruning on the lower bound. The file-level pruner keeps the stripped key. Rejected: evaluating with Nullable data_types against the non-Nullable key (chain functions would receive a type they were not built for); the whole universe for every NULL-bearing field (loses the lower-bound pruning ClickHouse#129929 added and tests). Closes ClickHouse#130040 Co-Authored-By: Claude Opus 5.5 <[email protected]>
Internal second-model review: adjudication log (click to expand)Pre-publication review by an independent model (engine: codex; 0 findings) plus my own review (1 finding below).
Severity: ❌ blocker / Session id: cron:clickhouse-review-slot-8:20261108-140100 |
Pre-PR validation gate (click to expand)
Session id: cron:clickhouse-impl-slot-40:20261108-124400 |
|
cc @scanhex12 @hanfei1991, could you review this and add the |
|
Workflow [PR], commit [847fdcc] Summary: ✅
AI ReviewSummaryPreserves Missing context / blind spots
Final VerdictStatus: ✅ Approve. No new inline findings to post. |
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
The official master build is compiled with Compile time of recompiled translation units35 translation units recompiled, 390 s compile time in total, 35 of them have a recent master baseline. |
…s set holds NULL
The data-file partition key is built from removeNullable(source type), and
ManifestFilesPruner evaluates a NULL partition value as the single point +inf.
For a non-Nullable key KeyCondition drops every NULL set element, so
has([NULL, 1], b) became {1}, nothing matched +inf, and the data file of the
NULL partition was skipped. Dropping the NULL element is exact only for a
partition tuple without NULL.
The pruner now also builds the same key over Nullable inputs, with its own
condition, and uses that pair only for a partition tuple holding NULL in a
Nullable key position (a void field has type Tuple() and never selects it).
Every other tuple keeps the existing key and condition.
A Nullable key for every file is not used: for an untyped set holding NULL,
such as [NULL, 5] (Array(Nullable(UInt8))), the has() atom is declined for a
Nullable(Int64) key (not safely castable, and canBeInsideNullable() is false
for a Nullable key), so files of tables without a NULL partition would no
longer be pruned. Accepting a Nullable key at that KeyCondition guard would
give the untyped set the typed shape that the Parquet row-group filter still
gets wrong (ClickHouse#128570, ClickHouse#128575), and is MergeTree-wide.
The manifest-list pruner (master only) is fixed separately by ClickHouse#130158.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
191bbbd
|
@groeneai @alexey-milovidov — ClickGap found the following in this PR:
Close anything that's wrong or already addressed. |
Cherry pick #130158 to 26.10: Fix Iceberg manifest-list pruning skipping NULL partitions for `ifNull`/`coalesce` filters
… NULL partitions for `ifNull`/`coalesce` filters
Backport #130158 to 26.10: Fix Iceberg manifest-list pruning skipping NULL partitions for `ifNull`/`coalesce` filters
Closes: #130040
Related: #129929
Related: #128575
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Description
On master, an Iceberg table with one manifest holding both a NULL and a non-NULL partition value returns
[]forWHERE ifNull(b, 0) IN (0)instead of the NULL row;coalesce(b, 0) IN (0, 1),assumeNotNull(b) IN (0)andNOT (ifNull(b, 0) >= 5)behave the same. #129929 introduced it (its merge returns[], its first parent the row) and it is inno release, hence
Not for changelog.Root cause. #129929 evaluates a field whose summary contains NULL as
[lower, +inf], butbuildPartitionKeyFromSpecstrips
Nullablefrom the key columns. For a non-Nullable typeifNull,coalesceandassumeNotNullreport themselvesmonotonic, the
+infbound stays untransformed, and[5, +inf]against the set{0}prunes the manifest.The change. The manifest-list pruner builds its key with the source columns' own types (
keep_nullable), as MergeTree'smin-max index does for a Nullable partition column, so those functions see a NULL-able range and decline. NULL-rejecting
filters still prune on the lower bound. The file-level pruner keeps its key unchanged.
Validation. New test
05573_iceberg_manifest_list_pruning_null_partition_ifnull(13 arms: the functions above, String,day and bucket fields, and sentinels that pin the manifest-prune counts) fails on master and passes here; 50 randomized runs
green. Three asserts in #129929's
test_manifest_list_partition_pruning.py(fails on master), and thetest_storage_iceberg_with_sparkpruning modules pass (33/33).Not changed here:
has([NULL, 1], b)from the issue still returns[]because the file-level pruner drops it (26.9 and 26.10do the same; a separate, pre-existing defect). A decreasing function inside, such as
ifNull(-b, 0) IN (0), additionallyneeds #128575, which makes
ifNull/coalesce/assumeNotNulldecline a NULL stand-in on the left bound too.Workflow [PR]
Sync PR [sync-upstream/pr/130158]
Version info
26.11.1.1702-master(included in26.11and later)26.10.11.3