Repository navigation
Keep the NULL partition in Iceberg data file pruning when the filter's set holds NULL - #130177
Conversation
…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]>
Condense the NULL-tuple key selection comment in ManifestFilesPruner::canBePruned to one line. 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 (3 nits, none blocking).
Severity: ❌ blocker / Session id: cron:clickhouse-review-slot-9:20261108-161900 |
Pre-PR validation gate (click to expand)
Session id: cron:clickhouse-impl-slot-7:20261108-150100 |
|
cc @scanhex12 @kssenii, could you review this and add the |
|
Workflow [PR], commit [3a9f806] Summary: ✅
AI ReviewSummaryThe PR fixes Iceberg data-file pruning discarding a Missing context / blind spots
Final Verdict✅ Approve. No code changes requested. Runtime CI validation remains pending. |
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, 397 s compile time in total, 35 of them have a recent master baseline. |
fedcee8
…se#130177 in ManifestFilesPruning)
…er's set holds NULL
DeltaLake::PartitionPruner built its partition key over removeNullable(type),
and canBePruned evaluates a NULL partition value (__HIVE_DEFAULT_PARTITION__) as
the point +inf. For a non-Nullable key column KeyCondition drops every NULL
element of a set, so has([NULL, 1], p) or p IN (NULL, 1) with
transform_null_in = 1 became the set {1}, nothing matched +inf, and the data
file of the NULL partition was skipped: its rows were silently lost. Dropping
the NULL element is exact only for a partition tuple without NULL.
The pruner now also builds the same tuple key over the table schema's own
types (Nullable for a nullable Delta field) and evaluates a partition tuple
that holds NULL against it, where NULL is an ordinary value of the key's type.
Tuples without NULL keep the existing condition, so their pruning is
unchanged. A Nullable key for every file would be correct too, but KeyCondition
declines an untyped NULL-holding set such as [NULL, 5] (Array(Nullable(UInt8)))
for a Nullable key, so has([NULL, 5], p) would stop pruning anything on tables
without a NULL partition. Accepting such sets for Nullable keys in KeyCondition
would change MergeTree as well, and would hand untyped NULL sets to the Parquet
row-group filter that still mishandles them (ClickHouse#128570, ClickHouse#128575).
Remaining loss: in a multi-column table a NULL-holding tuple is evaluated with
every nullable column Nullable, so an untyped NULL-holding integer set on
another nullable column no longer prunes that file (rows stay correct;
MergeTree with a Nullable partition key behaves the same).
The Iceberg data-file pruner had the same defect and gets the same design in
ClickHouse#130177.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Related: #130040
Related: #130158
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Fixed Iceberg partition pruning skipping the data files of a
NULLpartition when the filter's set holdsNULL, such ashas([NULL, 1], b).Description
On 26.10.2.103,
SELECT arraySort(groupArray(v)) FROM icebergLocal('<dir>/db/t') WHERE has([NULL, 1], b)over a Spark-written Iceberg table partitioned by a nullablebreturns[]instead of[2]; it is correct withuse_iceberg_partition_pruning = 0. 26.9.25.15 is the same.The data-file partition key is built over the non-
Nullablesource types, soKeyConditiondrops theNULLelement of the set, whileManifestFilesPrunerevaluates aNULLpartition value as+inf. Nothing in the set matches it, and the file is skipped.ManifestFilesPrunernow evaluates a partition tuple that holdsNULLagainst the same key built overNullableinputs. Tuples withoutNULLkeep the existing condition, so pruning of every other file is unchanged: aNullablekey for all files would stop pruninghas([NULL, 5], b)on tables without aNULLpartition, which the test checks.Scope: on master the manifest-list pruner drops the same partition too, which #130158 fixes.
b IN (NULL, 1)withtransform_null_in = 1also needs #128570 and #128575 (Parquet reader) to return theNULLrows; here only its pruned-file count is tested. The DeltaLake partition pruner stripsNullablethe same way and gives the same wrong result; it is not changed here.Validation: the new test
05575_iceberg_partition_pruning_null_in_setfails on master and passes with the fix (50 randomized runs); the Iceberg stateless tests and the Spark partition-pruning integration suites pass.Workflow [PR]
Sync PR [sync-upstream/pr/130177]
Version info
26.11.1.1699-master(included in26.11and later)