Repository navigation
Cherry pick #115832 to 26.6: Support decimal types for writing in data lakes - #116858
Merged
robot-clickhouse-ci-2 merged 12 commits intoAug 30, 2026
Merged
Conversation
Two defects in the manifest writer, both reported by CI: 1. Every partition field was serialized against `leafAt(0)` of the partition record, so only the first partition column got its own Avro node. With a multi-column spec, a later `Nullable` column built its `GenericUnion` from the first field's schema and a later decimal column used the first field's `fixed` size. Restore the lookup of the field index by name. 2. Decimal partition values were dispatched on the `Field` type, but `DateTime64` is also kept in a `DecimalField`, so a `DateTime64` partition was written as a `fixed` decimal instead of a `long`. That tripped `Logical error: 'schema->type() == avro::AVRO_FIXED' (STID: 1288-3bd5)` in `04501_iceberg_datetime64_partition_pruning` and failed `test_writes_field_partitioning`, which partitions by nine columns including a `DateTime64`. Dispatch on the partition column type instead. The `chassert` on the Avro node kind becomes a regular exception: in a release build it was a no-op and the writer would have produced a malformed manifest. Also, `icebergDecimalRequiredBytes` computed the width from a signed `Int256` whose intermediate `(1 << 255) - 1` overflows, and the new decimal decoder in `ManifestFilesPruning` silently left the value as a `String` when the byte count did not fit the type. Both are now computed on the unsigned type and report a malformed manifest as an error. Report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=115832&sha=latest&name_0=PR Related: #115832
`fixed` is a named Avro type, and the name was derived only from `(precision, scale)`, so `PARTITION BY (price_a, price_b)` with two `Decimal(18, 4)` columns emitted two definitions of the same name `decimal_18_4` into one manifest schema and failed schema compilation on insert. Include the partition field id in the name. Co-Authored-By: Claude Fable 5 <[email protected]>
The bound deserializer hard-capped decimal bounds at 8 bytes and reconstructed only `Decimal32` and `Decimal64`, so the `lower_bounds`/`upper_bounds` the writer now emits for wider decimals could never be turned into a `Range` and `IcebergMinMaxIndexPrunedFiles` never fired for them. Decode through the native type of the expected decimal, like the partition value decoding already does. Co-Authored-By: Claude Fable 5 <[email protected]>
…pruning Co-Authored-By: Claude Fable 5 <[email protected]>
The build failed with `readability-redundant-casting` on `deserializeDecimalBound`: `unscaled_value` already has type `NativeType`. CI report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=115832&sha=d0e193232635a4d06105487972ba49ecc2550194&name_0=PR&name_1=Build%20%28arm_tidy%29 PR: #115832 Co-Authored-By: Claude Fable 5 <[email protected]>
Address review: `OPTIMIZE TABLE ... MANIFEST` reads partition tuples back from the source manifests, where a decimal partition value is parsed from the Avro `fixed` as its raw bytes (a `String` field), and both rewrite paths feed that row straight back into `generateManifestFile` (and into the `entry_partition_summaries` of the manifest list). `makeDecimalFixedDatum` and `dumpDecimalValue` accepted only a typed `DecimalField` there, so compaction of any decimal-partitioned table threw on `safeGet`. Both serializers now also accept the read-back representation: the bytes already hold the unscaled value in two's-complement big-endian form, so they are re-padded to the target `fixed` width (partition values) or re-trimmed to the minimum length (partition summary bounds) instead of being decoded and re-encoded. Covered by `test_optimize_manifest_files_decimal_partition`, which fails with `Bad get: has String, requested Decimal` without the fix. Co-Authored-By: Claude Fable 5 <[email protected]>
Support decimal types for writing in data lakes
…ypick/26.6/115832 # Conflicts: # src/Storages/ObjectStorage/DataLakes/Iceberg/IcebergWrites.cpp # src/Storages/ObjectStorage/DataLakes/Iceberg/ManifestFilesPruning.cpp # tests/integration/test_storage_iceberg_with_spark/test_manifest_compaction.py
The 26.6 branch misses several master-only refactorings around Iceberg writes, so the mechanical merge needed adaptation: - `extendSchemaForPartitions` on 26.6 always assigns partition field ids as `1000 + i` (no `spec_has_all_ids` logic), so define `field_id` locally for the new `getAvroType` signature. - Add the `DataTypes/DataTypesDecimal.h` include to `Utils.cpp` and `ManifestFilesPruning.cpp` (`getDecimalPrecision`, `checkDecimal`). - Keep 26.6's pruning loop without the master-only `DateTime64` branch, but make it index-based to decode decimal partition values by type. - Drop `test_manifest_compaction.py`: `OPTIMIZE TABLE ... MANIFEST` does not exist on 26.6, so the compaction test cannot run there. Original PR: #115832
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Original pull-request #115832
Do not merge this PR manually
This pull-request is a first step of an automated backporting.
It contains changes similar to calling
git cherry-picklocally.If you intend to continue backporting the changes, then resolve all conflicts if any.
Otherwise, if you do not want to backport them, then just close this pull-request.
The check results does not matter at this step - you can safely ignore them.
Troubleshooting
If the conflicts were resolved in a wrong way
If this cherry-pick PR is completely screwed by a wrong conflicts resolution, and you want to recreate it:
pr-cherrypicklabel from the PRYou also need to check the Original pull-request for
pr-backports-createdlabel, and delete if it's presented thereThe PR source
The PR is created in the CI job