Repository navigation
Antalya 26.8 - Backport of #118596 - Do not store ClickHouse unsigned integers in narrower Iceberg types - #2878
Conversation
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 620a9ac98c
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| case TypeIndex::UInt32: | ||
| case TypeIndex::Int64: | ||
| return {"long", true}; |
There was a problem hiding this comment.
Widen UInt32 in ORC data files too
For tables created with IcebergLocal(..., 'ORC') or another ORC-backed Iceberg engine, this now declares UInt32 as Iceberg long, but the unchanged ORC writer still declares it as TypeKind::INT and serializes it through Int64(Int32(value)). Inserting a value such as 4000000000 therefore writes a negative 32-bit value while the manifest schema and bounds describe a positive 64-bit value, producing incorrect reads or a schema mismatch for Iceberg consumers. The Iceberg ORC write path must emit UInt32 as ORC LONG and preserve the unsigned value, including for nested fields.
Useful? React with 👍 / 👎.
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`.
mkmkme
left a comment
There was a problem hiding this comment.
🤖 [Posted by an LLM agent on behalf of @mkmkme]
The port of ClickHouse#118596 matches upstream. Using the recursive forEachChild in checkNoUInt64 in place of anyInTypeTree is equivalent, and the fork-only Decimal/Time handling is kept. The UInt64 check runs only on CREATE, so existing tables still attach. A few things before merge:
-
Iceberg regression fails because of this change. In
iceberg_2,export partition/.../datatypes/export part/accepted/accepted: UInt64,Nullable(UInt64)andArray(UInt64)error out. The suite still expects aUInt64export into Iceberg to succeed, and that is now rejected on purpose. The real error is hidden by a harness bug:NameError: name 'error' is not definedatexport_operations.py:393. These scenarios need to be updated or xfailed in clickhouse-regression, ideally with theerror(...)helper fixed as well. -
Iceberg tables created before this change with a
UInt32column (stored as Icebergint). See the inline comments. Inserts take their types from the ClickHouse table definition, not from the Iceberg schema. For such tables, the column bounds and the Avro type of an identity partition field would now be written aslongwhile the schema saysint. Could you check this with an insert into such a table, read back by ClickHouse and by Spark or PyIceberg? Upstream has the same gap, so a known limitation is also an acceptable outcome. -
Commit
18c5cbac("fix tests") copies changes that are already onantalya-26.8from #2875, #2876 and #2877, plus thetest_database_gluediskassertion. It merges with no net effect but adds noise. Merging the base branch in would have been cleaner.
The other CI failures look unrelated: ThinLTO cache download, S3 503 in 04074_where_large_int_boolean_predicate, and test_backward_compatibility/test_custom_s3_disk_remote_url_allow_hosts. DCO is red as well.
| case TypeIndex::Int16: | ||
| case TypeIndex::UInt32: | ||
| return dumpValue(static_cast<Int32>(applyVisitor(FieldVisitorConvertToNumber<Int64>(), field))); | ||
| case TypeIndex::UInt32: |
There was a problem hiding this comment.
🤖 [Posted by an LLM agent on behalf of @mkmkme]
The bounds are now written as an 8-byte long whenever the ClickHouse column is UInt32. The type comes from sample_block, which is the ClickHouse table definition, not the Iceberg schema. A table created by an earlier build with u UInt32 has Iceberg type int for that field. Inserting into it after the upgrade would write 8-byte bounds into an int field. Readers that require exactly 4 bytes for int bounds, like PyIceberg, may reject the manifest. Could the size be chosen from the Iceberg field type, or could this be confirmed safe with a test?
There was a problem hiding this comment.
This is half true.
It is false for the regular insert path this comment is referring to because the methods updateExternalDynamicMetadataIfExists and buildStorageMetadataFromState are called and load the sample block based on the schema specified in the iceberg metadata files.
On the other hand, export part / partition is affected. The problem is that with export the schema is validated only at export time in a single node, and shall not change afterwards. I`ll see if I can come up with a fix for that.
There was a problem hiding this comment.
| case TypeIndex::Date: | ||
| case TypeIndex::Date32: | ||
| return "int"; | ||
| case TypeIndex::UInt32: |
There was a problem hiding this comment.
🤖 [Posted by an LLM agent on behalf of @mkmkme]
Same concern for the manifest's partition schema. On a table created before this change, an identity partition on a UInt32 column whose Iceberg type is int would now get Avro type long in new manifests. That doesn't match the table's partition type.
PR #2878 Audit Review
VerdictOne Medium defect, narrow trigger. The fix itself is sound. The PR does what it says. New Iceberg tables no longer get The defect: the replica now derives destination columns from that JSON using its own Confirmed defectsConfiguration & version skewMedium: export to an Iceberg table with a geometry/geography column passes scheduling, then fails on every replica
Lower-severity notes
What was checked and found clean
Coverage
Assumptions and limits. Static reading of Operational readinessScope.
|
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 1ff487b276
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| json.set("file_already_exists_policy", String(magic_enum::enum_name(file_already_exists_policy))); | ||
| json.set("filename_pattern", filename_pattern); | ||
| json.set("write_full_path_in_iceberg_metadata", write_full_path_in_iceberg_metadata); | ||
| json.set("allow_lossy_cast", allow_lossy_cast); | ||
| if (!iceberg_metadata_json.empty()) |
There was a problem hiding this comment.
Preserve the obsolete flag in persisted task JSON
Keep serializing allow_lossy_cast for downgrade compatibility, even if the current version ignores it. A pending plain MergeTree partition export is persisted by MergeTreePartitionExportScheduler; after downgrading to the preceding version, its parser unconditionally reads this field with getValue<bool>, so every descriptor written here is rejected during table startup and the export is silently not resumed. Serializing the now-effective permissive value preserves compatibility with the old reader.
Useful? React with 👍 / 👎.
|
This is not a straightforward backport. Upstream changed the Iceberg serialization so that UInt32 is written as an Iceberg long instead of an int. That could break existing ClickHouse-created tables by writing 8 bytes into a 4-byte field. Upstream avoids it by ignoring the table's declared schema and inferring the destination types from the Iceberg metadata JSON on every insert. So a UInt32 column written to an old Iceberg table is cast to the int the metadata declares. Therefore, I had to implement the iceberg medatada schema derivation for exports as well. But it could not be a fresh metadata because the export operation pins the schema at scheduling time and it has to be consistent across replicas. By doing so, another problem came up: the types inferred / derived from the iceberg json schema were not "safely castable" according to the I then dropped this setting (export_merge_tree_part_allow_lossy_cast, kept only as an obsolete no-op) and always cast, even if lossy, just like The above means that some partitions might be rejected at scheduling time. |
…erg-unsigned-ints
CI triage for #2878 @
|
| Check | Verdict |
|---|---|
| Regression release iceberg_2 | |
| DCO | Signed-off-by). Not a code issue. |
Stateless tests (amd_binary, cas storage, parallel): 04890_iceberg_metadata_spec_violation_no_abort |
✅ Flaky. Already fails on the base branch. |
| Integration tests (amd_asan_ubsan, db disk, old analyzer, 6/8): 11 tests | ✅ Flaky or infra, not related to this PR |
| Regression release swarms | ✅ Pre-existing. Same 2 failures on #2939. |
| Grype Scan (keeper, server-alpine) | ✅ Pre-existing. Same 5 high/critical CVEs on #2939. |
| GrypeScanServer / Grype Scan | ✅ Infra. The job timed out. |
1. Regression release iceberg_2: caused by this PR (expected)
All failures are UInt64 or lossy-cast scenarios under /iceberg/export partition:
✘ [ Error ] '/iceberg/export partition/no catalog/replicated merge tree/datatypes/export part/accepted/accepted﹕ UInt64'
✘ [ Error ] '.../accepted﹕ Nullable(UInt64)'
✘ [ Error ] '.../accepted﹕ Array(UInt64)'
✘ [ Fail ] '.../casting/lossy/UInt64 narrows to Int32 without allow_lossy_cast'
✘ [ Fail ] '.../casting/out of bounds/Int64 above INT32_MAX rejected without allow_lossy_cast'
✘ [ Fail ] '.../casting/out of bounds/Int64 below INT32_MIN rejected without allow_lossy_cast'
✘ [ Fail ] '.../casting/out of bounds/UInt64 above INT64_MAX rejected without allow_lossy_cast'
(the same casting scenarios fail again under /ice catalog/)
Why it fails. This PR makes two deliberate changes that contradict what the suite expects:
- In
getIcebergType(src/Storages/ObjectStorage/DataLakes/Iceberg/Utils.cpp),UInt64now throwsBAD_ARGUMENTS("cannot be stored in Iceberg … Use Int64 or Decimal(20, 0) instead").UInt32now maps tolong. Theaccepted_uint64scenarios still expect UInt64 to map tolongand the export to succeed. export_merge_tree_part_allow_lossy_castis nowMAKE_OBSOLETE, and lossy casts are allowed by default. The... rejected without allow_lossy_castscenarios expect the export to fail when the setting is off, so they now fail.
One more thing hides the real server error in the UInt64 scenarios. The test helper itself crashes:
File ".../iceberg/tests/export_partition/steps/export_operations.py", line 393, in export_part
assert result.exitcode == 0, error(result.output)
NameError: name 'error' is not defined. Did you mean: 'Error'?
steps/export_operations.py uses error() but never runs from testflows.asserts import error.
Suggested fix. Nothing needs to change in this PR's code. The changes go in Altinity/clickhouse-regression, which I can't write to, so a human needs to make them:
- Move UInt64,
Nullable(UInt64)andArray(UInt64)fromaccepted_*torejected_*iniceberg/tests/export_partition/datatypes.py, gated on the release that contains this change. ExpectBAD_ARGUMENTS/ "cannot be stored in Iceberg". Update the docstring mapping (UInt32 -> long). - In
iceberg/tests/export_partition/casting.py, drop thelossyandout of bounds"rejected without allow_lossy_cast" scenarios for this version, or flip them to expect the cast to succeed the wayINSERT ... SELECTdoes. - Add
from testflows.asserts import errortoiceberg/tests/export_partition/steps/export_operations.py.
For comparison, iceberg_2 also fails on the unrelated PR #2939, but with a different error: ModuleNotFoundError: No module named 'iceberg.requirements.aggregate_states'. The UInt64 and lossy-cast failures above appear only on this PR.
2. DCO: caused by this PR's commits
None of the 11 commits on the branch has a Signed-off-by: trailer. DCO passes on other antalya-26.8 PRs, for example #2939. You can fix it in one of two ways:
- Have a maintainer override the check.
- Have the author sign off and push. Signing off existing commits rewrites history, which means a force push. I won't do that.
3. Stateless 04890_iceberg_metadata_spec_violation_no_abort: flaky, pre-existing
-primitive to complex rejected
+NOT REJECTED
Result: Failure is flaky (4/11 reruns failed).
- The PR doesn't touch this test.
- The same arm fails the same way on the unrelated PR Guard the list of custom disks not allowed by remote_url_allow_hosts #2939 (
Stateless tests (amd_debug, parallel), "3/10 reruns failed"). - It is a known flaky test on antalya-26.8. Validate Iceberg schema evolution before the constant column and row count shortcuts #2944 ("Validate Iceberg schema evolution before the constant column and row count shortcuts") looks like the fix in progress.
- Safe to ignore or re-run.
4. Integration tests (amd_asan_ubsan, db disk, old analyzer, 6/8): flaky or infra
test_restore_db_replica(9 failures): one root cause.node1.restart_clickhouse()hung for about 7.5 minutes and then failed (Cannot start ClickHouse, see additional info in logs). Every later test in the module then failed inprepare_dbwithConnection refused (172.16.1.10:9000). The 3 earlier "with restart" variants passed in the same run. The test covers Replicated databases, which this PR doesn't touch. I couldn't read node1's server log:logs.tar.gzis overblau-fetch's size limit. So the exact reason it didn't start is unconfirmed.test_quorum_inserts::test_insert_quorum_with_ttl:Replica doesn't have part '20110101_0_0_0' which was successfully written to quorum of other replicas. This is a replication timing race, unrelated to Iceberg.test_system_reload_async_metrics:assert 175 == (173 + 1). The periodic async-metrics update ran during the test's window. This is a timing race.
None of these tests failed on the other 13 antalya-26.8 PR reports I checked. That doesn't settle it either way. But none of them touches the code this PR changes, and the failure patterns (restart hang, timing races under ASan) point to flakiness. Suggest re-running the shard.
5. Regression release swarms: pre-existing
✘ [ Fail ] '/swarms/feature/node failure/cpu overload' (5m 3s)
✘ [ Fail ] '/swarms/feature/node failure/cpu overload all swarm nodes' (5m 7s)
Code: 209. DB::Exception: Timeout exceeded while reading from socket (... receive timeout 300000 ms): While executing Remote. (SOCKET_TIMEOUT)
The same two scenarios fail identically on #2939 (job), so this isn't caused by this PR.
6. Grype: pre-existing or infra
- The keeper and server-alpine images have 5 high/critical vulnerabilities, for example CVE-2026-124709 and CVE-2026-107494. Guard the list of custom disks not allowed by remote_url_allow_hosts #2939 has exactly the same counts.
GrypeScanServer / Grype Scanfailed withThe action 'Parse grype results' has timed out after 60 minutes. Its scan reports 0 high/critical vulnerabilities. This is an infra timeout.
Notes
- Several jobs show as
DROPPEDinresult_pr.json, including all 8Integration tests (amd_tsan)shards,Stress,AST fuzzerandBuzzHouse. So the PR's new and changed integration tests (test_writes_unsigned_integer_types.py, the export-to-Iceberg tests) were only exercised in the shards that ran. - This triage is based on the CI reports and logs only. I didn't rebuild or re-run anything locally.
|
@arthurpassos QA verification is done and looks good, but before I post the full report and add the
|
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes to CHANGELOG.md):
Do not store ClickHouse unsigned integers in narrower Iceberg types (ClickHouse#118596 by @scanhex12)
Drops
export_merge_tree_part_allow_lossy_castand allow it by defaultDocumentation entry for user-facing changes
...
CI/CD Options
Exclude tests:
Regression jobs to run: