Repository navigation
[Iceberg spec fix part 2]: Do not store ClickHouse unsigned integers in narrower Iceberg types - #118596
Conversation
|
Preview deployment for your docs. Learn more about Mintlify Previews.
|
|
Workflow [PR], commit [bba9044] AI ReviewSummaryThis PR fixes the forward path for new Iceberg tables by widening Findings❌ Blockers
Tests
Final Verdict
|
| case TypeIndex::UInt32: | ||
| case TypeIndex::Int64: | ||
| return {"long", true}; | ||
| case TypeIndex::UInt64: |
There was a problem hiding this comment.
Rejecting UInt64 only in getIcebergType closes the bug for new CREATE / ALTER, but it does not protect legacy Iceberg tables that were already created by older releases. IcebergMetadata::write still accepts the current sample_block, getAvroType still maps UInt64 to Iceberg long (Utils.cpp:697-700), and the write path still reinterprets UInt64 as Int64 when it serializes metadata (IcebergWrites.cpp:275-277 and 668-670; Field.cpp:1057-1061 explicitly allows UInt64 <-> Int64 safeGet).
That means an upgraded server can keep writing the original broken representation for existing UInt64 tables. Please add a write-time guard for tables whose current schema still contains UInt64 (or an attach/migration guard) instead of rejecting only future DDL.
… write `UInt32` bounds Rejecting `UInt64` only when ClickHouse builds the schema left tables created by older releases writable: their ClickHouse columns can still be `UInt64` over Iceberg `long`, or `UInt32` over Iceberg `int`, and values outside the signed range were silently wrapped. `IcebergStorageSink` now checks the columns against the current Iceberg schema and throws for any `UInt64`, and for `UInt32` backed by an `int` field. With that guaranteed, `UInt32` columns are always stored as `long`, so `canDumpIcebergStats` admits `UInt32` and the 8-byte bounds from `dumpFieldToBytes` are actually written. Address review: #118596 Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
These tests declare `UInt64` columns in Iceberg tables that ClickHouse creates, which is now rejected because Iceberg has no type for every `UInt64` value. None of them depends on the column being unsigned. CI report: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=118596&sha=ab5659415eca50326221a8d600c11413b627bf25&name_0=PR PR: #118596 Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
| } | ||
| } | ||
|
|
||
| void checkNoUInt64(const ColumnWithTypeAndName & column) |
There was a problem hiding this comment.
Restricting the write-time validation to UInt64 reopens the legacy UInt32 case that older releases could create. A table can still expose a ClickHouse UInt32 column over an existing Iceberg int field, but this sink no longer checks that combination before writing.
That is still unsafe in the current code:
- the Parquet schema/data path still emits
UInt32as a 32-bit field (src/Processors/Formats/Impl/Parquet/PrepareForWrite.cpp:351,src/Processors/Formats/Impl/Parquet/Write.cpp:1336-1338); - the manifest path now unconditionally accepts
UInt32stats and serializes them as 8-bytelongbounds (canDumpIcebergStats+dumpFieldToBytesin this file).
So INSERT into a legacy Iceberg int column can still publish data/metadata that do not match the table's signed-32-bit contract. Please keep the earlier schema-aware UInt32-over-int guard here (or reject such attachments earlier) instead of reducing the check to UInt64 only.
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
The official master build is compiled with Compile time of recompiled translation units10 translation units recompiled, 70 s compile time in total, 10 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. |
… insert The insert-time check in `IcebergStorageSink` could never fire: the columns of an Iceberg table are rebuilt from the Iceberg schema before each query, so a `UInt64` column declared over an existing Iceberg table reaches the sink as `Int64`. Check the declared columns in `IcebergMetadata::createInitial` instead, before the existing-table check, so `CREATE TABLE IF NOT EXISTS` with `UInt64` or `Array(UInt64)` over an existing Iceberg table throws too. `ATTACH` does not go through `createInitial`, so tables created by older releases still load. CI report: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=118596&sha=latest&name_0=PR PR: #118596 Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Iceberg `int` is a 32-bit *signed* integer and there are no unsigned types in the specification at all, but ClickHouse declared a `UInt32` column as `int`: `4294967290` was read back as `-6`. It now widens to `long`, which the specification also allows as a promotion of `int`. `UInt64` has no Iceberg counterpart, because `long` is the widest integer type, so it is rejected when creating or evolving a schema. Checking the values instead is not possible: the insert pipeline casts them to `Int64` before the sink sees anything, and that cast wraps silently. Existing tests that used `UInt64` for an id column now use `Int64`. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
… write `UInt32` bounds Rejecting `UInt64` only when ClickHouse builds the schema left tables created by older releases writable: their ClickHouse columns can still be `UInt64` over Iceberg `long`, or `UInt32` over Iceberg `int`, and values outside the signed range were silently wrapped. `IcebergStorageSink` now checks the columns against the current Iceberg schema and throws for any `UInt64`, and for `UInt32` backed by an `int` field. With that guaranteed, `UInt32` columns are always stored as `long`, so `canDumpIcebergStats` admits `UInt32` and the 8-byte bounds from `dumpFieldToBytes` are actually written. Address review: #118596 Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
The limitation was edited directly inside the `AUTOGENERATED` region of `iceberg.mdx`, which fails the docs check and would be dropped on the next regeneration. Put it into `registerStorageObjectStorage.cpp` instead, and drop the stale claim that ClickHouse cannot create `Decimal` Iceberg columns: it can since `Decimal` support for data lake writes, which also makes the `Decimal(20, 0)` suggestion for `UInt64` valid. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
These tests declare `UInt64` columns in Iceberg tables that ClickHouse creates, which is now rejected because Iceberg has no type for every `UInt64` value. None of them depends on the column being unsigned. CI report: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=118596&sha=ab5659415eca50326221a8d600c11413b627bf25&name_0=PR PR: #118596 Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
ClickHouse tables with `UInt32` over an Iceberg `int` field, or with `UInt64`, as created by older releases, must fail on `INSERT` instead of wrapping the values. A `UInt32` column in a table ClickHouse creates must keep values above the `Int32` range. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…check The insert-time check no longer compares the columns with the Iceberg schema: it only rejects `UInt64` anywhere in the column type, which needs no schema lookup. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
… insert The insert-time check in `IcebergStorageSink` could never fire: the columns of an Iceberg table are rebuilt from the Iceberg schema before each query, so a `UInt64` column declared over an existing Iceberg table reaches the sink as `Int64`. Check the declared columns in `IcebergMetadata::createInitial` instead, before the existing-table check, so `CREATE TABLE IF NOT EXISTS` with `UInt64` or `Array(UInt64)` over an existing Iceberg table throws too. `ATTACH` does not go through `createInitial`, so tables created by older releases still load. CI report: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=118596&sha=latest&name_0=PR PR: #118596 Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
`UInt64` columns are now rejected on `CREATE` of an Iceberg table. CI report: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=118596&sha=latest&name_0=PR PR: #118596 Co-Authored-By: Claude Opus 5.5 <[email protected]>
b2a1859 to
2fe48b5
Compare
CI report: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=118596&sha=2fe48b5c6ef0c94ad31e22a9b872014ba1ec3234&name_0=PR&name_1=Build%20%28arm_tidy%2C%201%2F4%29 PR: #118596 Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
@scanhex12 — ClickGap found the following in this PR:
Close anything that's wrong or already addressed. |
… 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]>
Master now rejects `UInt64` columns on `CREATE` of an Iceberg table (ClickHouse#118596), so the test failed before reaching the null-map statistics. The key type does not matter to what it checks. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…insert_109838` Master now rejects `UInt64` columns on `CREATE` of an Iceberg table (ClickHouse#118596), so `CREATE TABLE t_u64 (c0 UInt64) ENGINE = IcebergLocal(...)` throws. The four type-collapse cases ran as one multiquery, so the exception also skipped the `Date` and `DateTime64(6)` cases. Remove the `UInt64` case and run each remaining type in its own `clickhouse-local` invocation, so a failure in one case does not hide the others. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…unction_honors_structure` Master now rejects `UInt64` columns in an Iceberg schema (ClickHouse#118596), so `ALTER TABLE ice17 ADD COLUMN c Nullable(UInt64)` throws and aborts the rest of the session. Add the column as `Nullable(Int64)` instead, and declare it the same way in the `icebergLocal` structure arguments that read `ice17`. The values and the reference output are unchanged. The other `UInt64` declarations in the test are table function structures, which are not subject to the check. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Master now rejects UInt64 columns on CREATE of an Iceberg table (ClickHouse#118596), so the test failed with BAD_ARGUMENTS after the merge of master. The values are non-negative, so the reference is unchanged. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Fixes the tests that fail in CI after the backport of ClickHouse#118596: - `05303_optimize_empty_string_comparisons_distributed_low_cardinality` and `test_database_iceberg` create Iceberg tables with a `UInt64` column, which is now rejected. Use `Int64`. - `test_writes_modify_column` and `test_writes_modify_column_position` used `UInt32` as the type that Iceberg cannot tell apart from `Int32`. `UInt32` is now stored as `long`, so the change is recordable. Use `UInt16`, which is still `int`.
Iceberg doesn't have integer unsigned type, UInt32 should be converted as Int64
int — 32-bit signed integers — Can promote to long
long — 64-bit signed integers
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Do not store ClickHouse unsigned integers in narrower Iceberg types
Workflow [PR]
Sync PR [sync-upstream/pr/118596]
Version info
26.10.1.2183-master(included in26.10and later)