Repository navigation
Read Iceberg v3 variant columns from Avro data files - #130078
alexey-milovidov merged 1 commit into
Conversation
Iceberg v3 stores a `variant` in Avro as a record of two `bytes` fields, `metadata` and `value`, in the variant binary encoding. Iceberg requests `Dynamic` for it, but `AvroDeserializer::createDeserializeFn` had no `Dynamic`/`JSON` case for a record, so every such table failed with "Type Dynamic is not compatible with Avro record" (ClickHouse#129998). The per-value part of `Parquet::decodeVariantColumn` becomes `Parquet::VariantValueDecoder`, built once per column; the Parquet-only null policy (a leaf null or an empty blob from `input_format_null_as_default` is a missing value) stays in `decodeVariantColumn`, whose behaviour is unchanged. Avro carries its NULL in the union branch, so `decode` requires two encoded blobs and an empty `bytes` field is malformed. The Avro reader uses the decoder for a record of exactly two `bytes` fields named `metadata` and `value` (either order) when the requested type is `Dynamic`, `JSON` or `Nullable(JSON)`. avro-cpp drops unknown logical types, so the record is matched by structure plus the requested type, like an explicit `Dynamic`/`JSON` request in the Parquet reader. Two hooks: the record case (required, nested, one-branch unions) and the `[null, record]` union, which is handled before the generic branches so that NULL is kept with `input_format_null_as_default = 0` (Dynamic stores NULL) and with `Nullable(JSON)` (the generic branch would turn a variant null into `{}`). Schema inference is unchanged: without the logical type, inferring `Dynamic` would change every user record named `{metadata, value}`. `VariantEncoding.cpp` lives in the Parquet object library, which is built only with `USE_PARQUET`, while Avro and Iceberg need only `USE_AVRO`; it includes nothing from Arrow/Parquet, so it is also added to `dbms` when Avro is enabled without Parquet. Closes ClickHouse#129998 Co-Authored-By: Claude Opus 5.5 <[email protected]>
Internal second-model review: adjudication log (click to expand)Pre-publication review: my own cold review plus an independent model (engine: codex; 1 finding). No blocker or major finding, so the tree is unchanged by review.
Severity: ❌ blocker / Session id: cron:clickhouse-review-slot-8:20261108-050200 |
Pre-PR validation gate (click to expand)
Session id: cron:clickhouse-impl-slot-5:20261108-040300 |
|
cc @scanhex12 @Avogar, could you review this and add the |
|
Workflow [PR], commit [8350cdb] Summary: ✅
AI ReviewSummaryPR #130078 reads Iceberg v3 Findings❌ Blockers
Tests
Final VerdictStatus: ❌ Block. Make per-value decoding exception-safe and add the recovery regression. No new inline findings or thread changes were posted because the remaining issue already appears in the author's adjudication log. |
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
The official master build is compiled with Compile time of recompiled translation units13 translation units recompiled, 78 s compile time in total, 13 of them have a recent master baseline. |
2f038ad
Closes: #129998
Related: #130028
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Iceberg v3
variantcolumns in Avro data files can now be read: an Avro record of twobytesfields,metadataandvalue, is decoded with the variant binary encoding when it is read asDynamicorJSON, as for Parquet. Closes #129998.Description
Iceberg v3 stores a
variantin Avro as a record of twobytesfields,metadataandvalue. Iceberg asks theAvroformat forDynamic, butAvroDeserializer::createDeserializeFnhad noDynamic/JSONcase for a record, so any Iceberg table with Avro data files and avariantcolumn failed withType Dynamic is not compatible with Avro record(the Impala tablesiceberg_v3_variant_avroandiceberg_v3_variant_mixedfrom the issue). It never worked: the same error on 26.8, 26.9 and 26.10.The Avro reader now decodes such a record with the Parquet variant decoder, which this PR splits into a per-value
Parquet::VariantValueDecoder;decodeVariantColumnkeeps its null handling and its behaviour. The record is matched by its structure (exactly twobytesfields namedmetadataandvalue, in either order) and only whenDynamic,JSONorNullable(JSON)is requested, because avro-cpp drops thevariantlogical type. A[null, record]union is handled directly, so NULL is kept withinput_format_null_as_default = 0and forNullable(JSON), as in Parquet. Schema inference is unchanged.VariantEncoding.cppis also built when Avro is enabled without Parquet.Validation:
05568_avro_read_variantcovers optional and required records, swapped fields,JSON/Nullable(JSON), nesting inArray/Map/Tuple, and malformed or non-variant records. It fails on master, passes 50/50 with random settings, and removing either hook reddens it. The issue's tables give the values expected in #130028's05707_iceberg_impala_v3_variant. The Parquet variant tests and the Avro tests that run locally pass unchanged. The ORC counterpart is #130031.Workflow [PR]
Sync PR [sync-upstream/pr/130078]
Version info
26.11.1.1690-master(included in26.11and later)