Repository navigation
Fix Iceberg schema evolution of decimals widened inside arrays, maps and structs - #130114
Conversation
…and structs For a complex column, getSchemaTransformationDag built one EvolutionFunctionStruct whose result type was the new type. Its executable moves Fields between nested positions (id-based rename, reorder, add, drop) and inserts them into a column of that type, but never converts primitive leaves, so a decimal widened across a storage width (decimal(12, 4) -> decimal(20, 4), Decimal64 -> Decimal128) failed with "Bad get: has Decimal64, requested Decimal128" and the table was unreadable. int -> long and float -> double only worked because a Field stores them as Int64 and Float64. Top-level columns get a CAST in the DAG for the same promotions. The evolution function now returns the new structure in which every nested primitive changed by a legal promotion (allowPrimitiveTypeConversion, the predicate of the top-level branch) keeps its old type: struct fields matched by id, list element, map key and value. The DAG then casts that to the new type. A named-tuple CAST matches elements by name, and the names are the new ones on both sides, so it only changes leaf types. When nothing nested was promoted the DAG is unchanged. Closes ClickHouse#130024 Co-Authored-By: Claude Opus 5.5 <[email protected]>
Iceberg writers refuse map key updates, so the integration test can only widen a map value. Build the case from JSON schemas instead: a decimal(9, 2) map key widened to decimal(18, 2) is read through the transformation DAG as Map(Decimal(18, 2), Nullable(Int32)) with the value preserved. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Shorten the getSchemaTransformationDag comment on the post-evolution cast 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; 1 finding over 2 rounds; round 2 on the fix commit found nothing).
Severity: ❌ blocker / Session id: cron:clickhouse-review-slot-11:20261108-092500 |
Pre-PR validation gate (click to expand)
Session id: cron:clickhouse-impl-slot-4:20261108-065900 |
|
cc @scanhex12 @arsenmuk, could you review this and add the |
|
Workflow [PR], commit [d96dc8f] Summary: ✅
AI ReviewSummaryThe PR fixes Iceberg decimal widening inside nested containers by preserving the original primitive types during structural evolution, then applying Consumer trace: Missing context / blind spots
Final VerdictStatus: ✅ Approve. No code changes requested; CI validation remains pending. |
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
The official master build is compiled with Object file sizes4 object files changed (+63.52 KiB total), 0 added.
719 more object files are built by the master warmup baseline only (it builds every object-file target, a pull request build only Compile time of recompiled translation units51 translation units recompiled, 542 s compile time in total, 51 of them have a recent master baseline. |
2ba2cfd
Closes: #130024
Related: #130016
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Fixed reading Iceberg tables in which a decimal inside an array, a map or a struct was widened to a precision with a wider storage type (for example
decimal(12, 4)todecimal(20, 4)): every query to such a table failed withBad get: has Decimal64, requested Decimal128.Description
On 26.10.2.103 and 26.3.60.2,
SELECT * FROM icebergLocal(...)on the Apache Doriscomplex_*_schema_changetables from #130016 fails withBAD_GETinEvolutionFunctionStruct:col3islist<decimal(12, 4)>in the data files andlist<decimal(20, 4)>in the current schema, a legal Iceberg promotion.For a complex column,
IcebergSchemaProcessor::getSchemaTransformationDagadds oneEvolutionFunctionStructwhose result type is the new type. It renames, reorders, adds and drops nested fields onFields and inserts them into a column of that type without converting the primitive leaves, so aDecimal64field lands in aDecimal128column. Top-level columns get aCASTin the DAG for the same promotions; nested ones got none.Now the evolution function returns the new structure in which every nested primitive changed by a legal promotion (
allowPrimitiveTypeConversion, as for top-level columns) keeps its old type (struct fields matched by id, list element, map key and value), and the DAG casts the result to the new type. When nothing nested was promoted, the DAG is unchanged.Validation: the new integration test
test_decimal_evolved_nested(Decimal32 to Decimal64 and Decimal64 to Decimal128 in an array, a map value, a struct field and an array of structs, together with a rename, a reorder and an added field) fails on master and passes with the fix. The gtestIcebergSchemaProcessor.WidenMapKeyDecimalAcrossSchemaIdscovers a widened map key, which Iceberg writers do not produce. The four Doris tables return their 15 rows, and the schema-change part of #130016's05721_iceberg_doris_schema_evolutionmatches its reference exceptrename_col7.add, a struct subcolumn read that fails without any promotion too (#125252). Thetest_storage_iceberg_schema_evolutionpackage passes.Workflow [PR]
Sync PR [sync-upstream/pr/130114]
Version info
26.11.1.1684-master(included in26.11and later)