Repository navigation
Conversation
…rtitions A manifest-list field summary that says `contains_null = false` and carries no `lower_bound` states that the partition field holds no orderable value, so a spec-compliant manifest evaluator (pyiceberg `_ManifestEvalVisitor`, Java `ManifestEvaluator`) answers ROWS_CANNOT_MATCH and skips the whole manifest. A filtered external scan of such a table therefore returned no rows while the table was full of data. Measured with pyiceberg 0.11.1 on a two-row table partitioned by `icebergBucket(16, s)`: `scan()` gives 2 rows, `scan(row_filter="s == 'eu'")` gives 0. ClickHouse's own reader substitutes infinities for a missing bound, which is why CI never saw it. Reported as issue ClickHouse#118905; the summary writer reached the INSERT path in ClickHouse#118796. Two coupled mistakes produced it. First, the Iceberg partition field type was taken from the ClickHouse transform function rather than from the transform. The spec fixes `bucket[N]` as an `int`, while `icebergBucket` returns `UInt32`, which is outside the accept-list of `canDumpIcebergStats` even though `getAvroType` already declares it as Avro "int" and `dumpFieldToBytes` already has a 4-byte arm for it. `ChunkPartitioner` now publishes `Int32` for a `bucket[N]` field and converts the transform result column to it before the partition keys and the scatter selector are taken, so the stored value, the published type and the grouping stay in agreement. The conversion cannot change a value: `icebergBucket` rejects `N <= 0 || N > INT32_MAX` and returns `positiveModulo(hash & INT32_MAX, N)`, which is in `[0, N)`. Nullability is carried through so a `Nullable` source keeps its Avro ["null","int"] union. Broadening `canDumpIcebergStats` instead was rejected: ClickHouse#118596 moves `UInt32` to the 8-byte branch of `dumpFieldToBytes` and `getAvroType(UInt32)` to "long", so an admitted `UInt32` bound would become 8 bytes for a 4-byte `int` field, reinstating the defect fixed in ClickHouse#117571; and that predicate is shared with `canWriteStatistics`, the per-column data-file gate. Changing the functions' own return types was rejected too: `icebergBucket` is a general SQL function, so a MergeTree table may use it in `PARTITION BY`, where `KeyDescription` re-derives the key type from the current function on every table load while the existing `partition.dat` files hold the old serialization. Second, the writer published a contradictory record instead of declining to describe what it cannot serialize. `generateManifestList` now leaves the optional `partitions` list out when a tuple holds an orderable value whose bound cannot be written, and drops a list carried forward from a parent snapshot when that list makes the same claim. Without the second half, a table written by an affected build keeps republishing its bad summaries through every later INSERT, DELETE and UPDATE. The carry-forward check fails closed and never throws: `partitions` is optional, so dropping it costs a reader one unskippable manifest, whereas throwing would make a manifest list written by another engine unmergeable. NULL and NaN keep today's behaviour, which is what the reference implementation writes and is true of them. The `truncate` bound width, the second half of issue ClickHouse#118905, is deliberately not fixed here, so the issue stays open. `ChunkPartitioner` passes the transform width as `UInt64` and `positiveModulo` loses the sign of a negative left operand, so the write path stores a wrong partition value: an Iceberg table `PARTITION BY icebergTruncate(10, i32)` holding -1 answers `SELECT count() FROM t WHERE i32 = -1` with 0. Narrowing that bound first would replace pyiceberg's loud `struct.error` with a silently pruned manifest, so the width follows the value fix. The `year`, `month`, `day` and `hour` transforms have the same defect as `bucket` and ClickHouse#118583 already fixes them by returning `Int32`, which flows through this path with no further change. Nothing about the encoded partition value or the declared Avro type changes, so no setting and no `SettingsChangesHistory` entry is involved and existing tables read back unchanged. Related: ClickHouse#118905 Co-Authored-By: Claude Opus 5 <[email protected]>
…g path The published `Int32` partition-key type was asserted nowhere. Deleting the conversion in `ChunkPartitioner::partitionChunk` left all existing tests green, because every output downstream of it is identical either way: `Field::safeGet` permits the `UInt64`/`Int64` slot interchange, `getAvroType` maps both to Avro "int", and `make_value_datum` handles both Field tags in one arm. So the header contract could silently become false under a later refactor. The difference is not observable from SQL, which is what makes a gtest the right tool here: the two new cases assert the Field's own tag, the only thing that distinguishes the published type from the transform function's return type. Writing a real bound is also what first activates ClickHouse's own manifest-list pruning for a bucket spec, since a missing bound made `ManifestListPruning` substitute infinities and never skip a manifest. The bucket-transform test now also reads the table back through a filter, so that path is exercised rather than assumed. Co-Authored-By: Claude Opus 5 <[email protected]>
Internal second-model review: adjudication log (click to expand)Pre-publication review by an independent model (engine: codex) plus a separate cold reviewer pass,
Severity: ❌ blocker / Two adjacent things I noticed and am deliberately not changing here, for the record: Session id: cron:clickhouse-review-slot-9:20260911-173600 |
Pre-PR validation gate (click to expand)
Session id: cron:clickhouse-impl-slot-6:20260911-171100 |
|
cc @alesapin @SmitaRKulkarni, could you review this? The Iceberg partition field type was taken from the ClickHouse transform function rather than from the transform, so |
|
Workflow [PR], commit [9bf2212] Summary: ✅
AI ReviewSummaryThe PR publishes Iceberg Consumers of the changed partition-key representation were traced:
The earlier temporal-transform finding is resolved. The author's decision to exclude mixed null/NaN summaries from affected pre-release master builds is accepted: both the multi-partition writer and float-bound support entered Final VerdictStatus: ✅ Approve |
`getResultTypes()` described itself as "the Iceberg partition field types", but `icebergPartitionFieldType` corrects only `bucket[N]`. The `year`, `month`, `day` and `hour` transforms are computed by `toYearNumSinceEpoch`, `toMonthNumSinceEpoch`, `toRelativeDayNum` and `toRelativeHourNum`, which return `UInt16` or `UInt32`; the Iceberg specification has no unsigned type, so for those specs the accessor hands back a ClickHouse type rather than an Iceberg one. A caller trusting the old wording would have assumed a conversion that does not happen. The compaction test's docstring described the encoder serializing the transform's unsigned result. Compaction reads the published type, so it now serializes the Iceberg `int` instead. Both reach the same four-byte cast in `dumpFieldToBytes`, so the bytes written are unchanged. Comment text only. The rebuilt binary is byte-identical. Co-Authored-By: Claude Opus 5 <[email protected]>
`OPTIMIZE TABLE ... MANIFEST` rewrites the manifest list through its own `generateManifestList` call, so it writes field summaries of its own. Nothing asserted them: the existing compaction test reads the table only unfiltered, which holds whether a summary carries a correct bound, carries none, or is absent. The new arm decodes the rewritten manifest list. It pins the four pre-OPTIMIZE entries and the manifest-list name, because a compaction that silently does nothing leaves summaries satisfying the same oracle, and it resolves the newest snapshot by `(last-updated-ms, metadata version)` instead of through `get_last_snapshot`, whose timestamp-only comparison leaves a same-millisecond tie to `os.listdir` order. On the parent commit the arm fails on the bound, giving `[(False, None, None, None)]` where the fix gives `[(False, None, b'\x06\x00\x00\x00', b'\x06\x00\x00\x00')]`, so compaction was writing the same empty-range claim as the insert path. Co-Authored-By: Claude Opus 5 <[email protected]>
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
The official master build is compiled with Compile time of recompiled translation units17 translation units recompiled, 120 s compile time in total, 17 of them have a recent master baseline. Median compile-time ratio to the baselines is ×1.06 (machine-speed difference or a change affecting every TU); per-TU deltas below are relative to that ratio. |
CI finish ledger - c9a8d62Every failure below has an owner: a fixing PR (mine or external), or a full-effort fix task
Two notes on reading the rest of this run, neither of them an unowned failure:
The On the first row, in the interest of not overstating a link: #117311 is an in-flight fix in this Session id: cron:our-pr-ci-monitor:20260912-020037 |
…t-list-bucket-partition-summary # Conflicts: # src/Storages/ObjectStorage/DataLakes/Iceberg/IcebergWrites.cpp
ClickHouse#118583 made the `year`, `month`, `day` and `hour` partition transforms return `Int32`, so after merging master the claim that they publish an unsigned type no longer holds. Co-Authored-By: Claude Opus 5.5 <[email protected]>
CI finish ledger - 5d73983Every failure below has an owner: a fixing PR (mine or external), or a full-effort fix task
None of these touches the Iceberg manifest-list partition summaries this PR changes. All 160 checks completed; apart from the expected inverted rows of the two green Session id: cron:our-pr-ci-monitor:20261003-173335 |
|
Fixing PR for 05237_with_expression_alias_scope_descendant (DBReplicated): #123774 |
… filtered in Spark Since ClickHouse#118596 maps `UInt32` to Iceberg `long`, a `bucket[N]` partition field whose type comes from the transform's `UInt32` result is declared Avro `long` with 8-byte manifest-list bounds, and Spark/PyIceberg fail a read filtered on the bucketed column (ClickHouse#125366). This PR publishes `Int32` for that field, so the declared type stays `int` on current master as well. - The no-Spark compaction arm now asserts the declared Avro type of the manifests `OPTIMIZE ... MANIFEST` writes, which it previously did not check. - The Spark compaction test reads the table back filtered on `id = 5`. Iceberg projects only `=`/`IN` through `bucket`, so equality is what makes Spark evaluate the rewritten partition values and bounds. - Two comments that said the manifest declares `int` "before and after this fix" / "keeps" the union are no longer true on master and are reworded. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The test inserted 4 batches that each covered all 4 buckets, so the table already had one manifest per partition, `OPTIMIZE ... MANIFEST` returned early without writing anything, and Spark read only its own metadata. Every Spark read in the test, including the filtered one from the previous commit, passed on master for that reason. Insert 8 batches instead (same 80 rows), so compaction rewrites the manifests, and check that it committed a `replace` snapshot before Spark reads the table. The read filtered on `id = 5` now fails on master and passes with this PR. A range filter on `id` fails on master too, so equality is not the only predicate that reaches the rewritten partition values, as the previous commit message suggested. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The docstring described only the encoder exception the test was first written for. Say what it checks now: compaction writes the bucket field as the Iceberg `int`, so Spark can read the rewritten table filtered on the bucketed column. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Shorten the four comment blocks to their invariants and drop the one on where the bucket cast sits. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Internal second-model review: adjudication log (click to expand)Test-only round for #125366 (no
Severity: ❌ blocker / |
Pre-PR validation gate (click to expand)
Session id: cron:clickhouse-impl-slot-6:20261014-084100 |
|
cc @scanhex12 @SmitaRKulkarni, could you review this? |
…t-list-bucket-partition-summary # Conflicts: # tests/integration/test_storage_iceberg_interoperability_local/test_interoperability.py
CI finish ledger - 8b1a8d2Every failure below has an owner: a fixing PR (mine or external), or a full-effort fix task
The Session id: cron:our-pr-ci-monitor:20261102-173007 |
…t-list-bucket-partition-summary Conflict in IcebergWrites.cpp: master (ClickHouse#128880) now aggregates the manifest-list partition summary over all entries of a manifest (`ManifestPartitionSummary`, with `bounds_unavailable` per field) instead of passing one (value, type) pair per field. `canWritePartitionSummary` now checks `bounds_unavailable`, so a manifest with any value that has no Iceberg bound serialization still omits the optional `partitions` field rather than publishing a field summary without bounds, which readers take as "only nulls or NaNs". The write loop takes master's form; its `bounds_unavailable` check and comment are dropped because the guard above already returns early. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…t-list-bucket-partition-summary Conflict in IcebergWrites.cpp, two hunks: - The summary write loop: master (ClickHouse#129812) only reworded the comment on its `bounds_unavailable` check. Kept this branch's form, which has no check: `canWritePartitionSummary` already returns early for a manifest with such a field. - The manifest-list carry-forward: master (ClickHouse#130800) rebuilds each count in the new list's shape with `copy_count`. Took master's counts and kept this branch's guarded copy of `partitions`. Conflict in ChunkPartitioner.h: master added `[[nodiscard]]` to `getResultTypes`; kept it together with this branch's comment. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Since ClickHouse#129812 the Iceberg writer serializes `Float32`/`Float64` bounds, including in the manifest-list partition summary, so the tuple holding 1.5 now gets a bounded summary instead of none. No other partition type that ClickHouse can write lacks a bound serialization any more (`UUID` partitions are rejected at INSERT), so the test now asserts the real bound and keeps the NaN case, which still has no bound and must keep its summary. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Closes: #125366
Closes: #118930
Related: #118905
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
The manifest-list field summary that ClickHouse writes for an Iceberg
bucketpartition carried null bounds next tocontains_null = false, which a spec-compliant reader reads as "this field holds no values" and uses to skip the whole manifest, so a filtered scan of such a table returned no rows. Abucketpartition field is now described as the Icebergintthe specification gives it, so its bounds are written, and a summary whose bounds cannot be serialized is omitted instead of claiming an empty range, on newly written and on carried-forward manifest-list entries alike.Description
A field summary with
contains_null = falseand nolower_boundstates that the partition field holds no orderable value, so a manifest evaluator answersROWS_CANNOT_MATCHand skips the manifest. 26.9 writes exactly that for abucketspec, becausecanDumpIcebergStatsdoes not accept theUInt32thaticebergBucketreturns. Measured with pyiceberg 0.11.1 on a two-row bucket-partitioned table written by 26.9.1.1629:scan()returns 2 rows,scan(row_filter="s == 'eu'")returns 0. Since #118596 (26.10) the bucket field is Avrolongwith 8-byte bounds: those filtered reads throw in Spark and PyIceberg (#125366), and Spark ignores ClickHouse's partition-scoped position deletes, so rows removed byDELETE/UPDATEcome back (Data lake fuzzer, #128538). Measured on master, two buckets of two data files each: afterDELETE WHERE id % 2 = 0ClickHouse reads 10 rows and Spark 20, after the sameUPDATE20 and 30; with this PR, 10 and 20.ChunkPartitionerpublishes the Iceberg field type of abucket[N]transform,int, and converts the transform result to it. The conversion is exact:Nis validated to(0, INT32_MAX]and the result is in[0, N). INSERT, mutations and both compaction writers take their partition types from it, so all of them writeintwith 4-byte bounds, whileUInt32columns keep thelongmapping of [Iceberg spec fix part 2]: Do not store ClickHouse unsigned integers in narrower Iceberg types #118596.generateManifestListno longer publishes an empty-range claim: a tuple with an unserializable bound gets nopartitionslist (that field is optional), and a list carried forward from the parent snapshot is dropped rather than copied when it makes that claim. Without the second half an affected table keeps republishing its bad summaries through every later INSERT, DELETE and UPDATE. NULL and NaN are unchanged.#118905's
truncatebound width is left out; that issue stays open.year/month/day/houralready get real bounds: #118583 made those transforms returnInt32.Workflow [PR]
Sync PR [sync-upstream/pr/119514]