Skip to content

Fix Iceberg Avro writer emitting optional complex fields as required - #112648

Merged
PedroTadim merged 2 commits into
ClickHouse:masterfrom
groeneai:groeneai/iceberg-avro-optional-complex-union
Jul 31, 2026
Merged

PedroTadim merged 2 commits into
ClickHouse:masterfrom
groeneai:groeneai/iceberg-avro-optional-complex-union

Conversation

@groeneai

@groeneai groeneai commented Jul 30, 2026 •

Copy link
Copy Markdown
Collaborator

Changelog category (leave one):

  • Bug Fix (user-visible misbehavior in an official stable release)

Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):

Fixes an Iceberg table whose write format is Avro serializing a field declared "required": false whose type is a list, map or struct as required, with no ["null", T] union, so that the data file's own schema disagreed with the table metadata and other Iceberg readers saw a required field. Such a field is now written as the ["null", T] union the Iceberg spec uses for an optional one.

Description

AvroSerializer::createSchemaWithSerializeFn emits a ["null", T] union only for Nullable and Variant, so Avro nullability came purely from the type carrying a Nullable wrapper. The Iceberg read layer never puts that wrapper on a container: IcebergSchemaProcessor::getFieldType calls makeNullable only on the scalar branch, while the complex branch returns a bare Array/Map/Tuple regardless of the field's own required bit. An optional container's optionality is therefore unrecoverable from the type.

This is the Avro half of #111775, which fixed the same defect for ORC and added the per-path metadata this consumes.

The fix adds createFieldSchemaWithSerializeFn, used at the four sites that own a field (top-level column, tuple field, array element, map value). It consults that metadata and wraps the built schema in ["null", T], unless the schema is already a union or null, so the union is added exactly once per path.

getIcebergType publishes required: true for ClickHouse-authored containers, so the carrier is normally an externally authored schema written by ClickHouse with 'Avro'. The one exception is Nullable(Tuple), the only container ClickHouse DDL can declare optional. Field ids are unchanged and plain FORMAT Avro output is byte-identical.

At the default input_format_null_as_default = 1 such a file reads back unchanged. With the setting off the read throws Cannot insert Avro Union(Null, T) into non-nullable type T, because getFieldType derives a bare container for an optional complex field, the standing reader limitation Spark-written files already hit. For a Nullable(Tuple) column it is a change: master wrote a bare record, readable at either value, so with enable_nullable_tuple_type = 1 (default off) and the setting persisted off at CREATE, a read that worked now errors. Optional element, value and field positions are unaffected, their targets being Nullable. The reader derivation is the root cause and is tracked separately.

Validation: per-field nullability in the written file's schema, master vs fix

Fixture: hand-written v1.metadata.json with optional and required containers, CREATE TABLE IF NOT EXISTS ... ENGINE = IcebergLocal(dir, 'Avro'), one INSERT. Values read out of the written file's avro.schema header entry.

field (Iceberg) master with fix
req_int required int required int required int
opt_int optional int optional int optional int
opt_list optional list required array optional array
opt_map optional map required map optional map
opt_struct optional struct required record optional record
req_list / req_map / req_struct required required required
list_opt_elem.element, map_opt_val.value, opt_struct.sy optional optional optional
list_opt_struct_elem.element optional struct required record optional record
struct_opt_list_field.inner optional list required array optional array
map_opt_struct_val.value optional struct required record optional record

Each of the four call sites is pinned separately: reverting one at a time to createSchemaWithSerializeFn moves a disjoint set of reference lines, the top-level site moving opt_list/opt_map/opt_struct, and the array-element, tuple-field and map-value sites moving one nested line each. All 13 Iceberg field ids are byte-identical between the arms, and the test also pins them at depth: not descending through the union drops four nested-id lines. 50/50 green, and 20/20 green under compatibility='20.1', the regime whose pre-21.1 input_format_null_as_default default the read-back pin defends.

Version info

  • Merged into: 26.8.1.487 (included in 26.8 and later)

groeneai added 2 commits July 29, 2026 15:57
AvroSerializer::createSchemaWithSerializeFn builds an avro::UnionSchema in
exactly two arms, Nullable and Variant; the Array, Tuple and Map arms build
bare container schemas. Avro nullability therefore came purely from the
ClickHouse type carrying a Nullable wrapper.

The Iceberg read layer never puts that wrapper on a container:
IcebergSchemaProcessor::getFieldType calls makeNullable only on its scalar
branch, while the complex branch returns a bare Array, Map or Tuple regardless
of the field's own required bit (the bit is read only to type a struct's
children). So an Iceberg field declared "required": false whose type is a
list, map or struct reached the writer without a Nullable and was serialized
into the data file as required, contradicting the table metadata describing it
and making the file non-conformant for other Iceberg readers.

This is the Avro half of ClickHouse#111775, which fixed the same defect for the ORC
writer and introduced the per-path iceberg_optional_paths metadata that ORC was
so far the only consumer of.

Add createFieldSchemaWithSerializeFn and use it at the four sites that own a
field: the top-level column, a tuple field, an array element and a map value.
It consults the per-path metadata and wraps the built schema in ["null", T],
skipping schemas whose root is already a union or null because those carry
their own optionality; that keeps the union emitted exactly once per path, so
Nullable(Tuple) at an optional path stays a single union instead of becoming an
invalid nested one. The three container arms are unchanged, and the three
transparent same-path recursions (Nullable, LowCardinality, Variant) keep
calling the raw helper so they cannot introduce a second union.

Map keys deliberately stay outside this path: they never go through
createSchemaWithSerializeFn, which matches collectOptionalPaths forcing a map
key required per the Iceberg spec.

Behaviour is unchanged without the metadata, so plain FORMAT Avro output is
byte-identical, and Iceberg field ids are unaffected because
setIcebergFieldIds already descends through a union without extending the path.
The Parquet writer expresses optionality through FieldRepetitionType, a
different mechanism, and is tracked separately.
Fix round r1. Test-only; the writer seam and the reader are unchanged.

Gate B was right that the previous fixture pinned only one of the four
changed call sites: every optional NESTED path in it was a primitive, so
its union came from the pre-existing Nullable arm rather than from the new
boundary wrapper. Add one optional COMPLEX payload per nested owner
position (Array(Tuple) element, Tuple field of list type, Map value of
struct type). Reverting each site individually now moves a disjoint set of
reference lines, so all four are covered.

Tighten the union oracle to require exactly the 2-branch null-first form,
so a wrong arity or a swapped branch order fails instead of also reading as
"optional", and assert Iceberg field ids at every depth rather than only at
the root: not descending through the union drops four nested-id lines.

Pin input_format_null_as_default for the read-back. It has to sit on the
CREATE TABLE, not on the SELECT: a table engine freezes its format settings
at creation and ignores the session ones afterwards, so a per-statement pin
cannot reach the reader. Without it, a run that injects an old compatibility
value gets the pre-21.1 default of false, under which the union an optional
container now carries has no legal target, because Array and Map cannot be
Nullable in ClickHouse. Add that throw as an assertion of its own, read
through file() so the setting is statement-local, with a required container
as the control.

The trailing grep also had to stop deciding the script's exit status: a grep
that matches nothing exits 1, and the runner fails a .sh test on any nonzero
return code even when its output matches the reference.
@groeneai

Copy link
Copy Markdown
Collaborator Author
Internal second-model review: adjudication log (click to expand)

Pre-publication review by an independent model (engine: codex; 2 gate passes, 1 finding), plus my own
cold review of the resulting code taken before reading the author's evidence. 8 findings across the
two rounds: 5 AGREE, 1 DISAGREE, 2 dropped. Every AGREE was verified against the code before it was
accepted.

# Sev Finding Verdict Evidence / action
1 ❌ The new test's final read-back was unpinned, so it would fail on the stress draws that inject an old compatibility value and revert input_format_null_as_default to its pre-21.1 default of false, under which ["null", array] has no legal target AGREE, fixed @ a4f09bf Chain verified: the reader resolves against the file's own schema (AvroRowInputFormat.cpp:1162), and for a non-Nullable Array the union arm takes neither the nullable nor the null-as-default branch and throws at :528. The history entry sits in the 21.1 block of SettingsChangesHistory.cpp, so 12 of 84 draws revert it. Pin added
2 ⚠️ Only one of the four changed call sites was pinned: every optional nested path in the fixture was a primitive, whose union comes from the pre-existing Nullable arm, and the only optional containers were top level AGREE, fixed @ a4f09bf Confirmed by parsing the fixture. It now carries an optional complex payload at each nested owner position, so reverting each site individually moves a disjoint set of reference lines, measured over four separate builds
3 ⚠️ The read consequence was framed as purely pre-existing reader behaviour, but for a file ClickHouse itself wrote it is a change: master emitted a bare container, which read at either setting value AGREE, fixed @ a4f09bf AvroRowOutputFormat.cpp:338 pre-diff versus the union arm post-diff. The Description and the validation gate now state the accurate scope, and that regime is exercised rather than only described
4 ⚠️ The changelog entry named write_format = 'Avro', which is an internal C++ member and not anything a user can type AGREE, fixed pre-publication IcebergWrites.cpp:865; no setting of that name exists in src/Core, src/Formats or the docs. The user-facing surface is the engine argument documented as IcebergLocal(path_to_table, [,format] [,compression_method]). Reworded to "whose write format is Avro"
5 💡 Optional element, value and field positions are safe on read while optional container positions are not, and the body did not name the asymmetry AGREE, fixed @ a4f09bf Their targets are Nullable so they take the nullable union arm, whereas Array and Map cannot be Nullable. One clause added
6 💡 The new test should carry no-replicated-database, as two sibling IcebergLocal tests do DISAGREE Those two tag for a materialized-view refresh and a schema-rebinding scenario this test does not exercise. The closest structural precedents, the IcebergLocal tests that also hand-write a metadata JSON, carry only no-fasttest. Adding the tag would drop this test from that lane for no measured reason
7 💡 Provenance should be an explicit Related: line outside the leading comment dropped Not a defect: the requirement is that the link is visible in the rendered body, and the Description renders it
8 💡 Second gate pass, delta from the previously reviewed head dropped 0 findings. Both reported diffstats matched the intended change set, so the pass ran on the right base

Two claims made during the rounds were corrected rather than carried forward. The first prescribed
location for the read-back pin is provably inert, because a table engine freezes its format settings
at CREATE and ignores session ones afterwards (registerStorageObjectStorage.cpp:56), so the pin
sits on the CREATE and the negative cell reads the written file through file instead. And losing
the double-wrap guard surfaces as Code: 1001 std::exception rather than the underlying Avro
message, which is not preserved.

Severity: ❌ blocker / ⚠️ major / 💡 nit. DISAGREE verdicts carry recorded evidence and are
terminal per finding. Findings on hunks unchanged by the fix round are auto-dropped.

Session id: cron:clickhouse-review-slot-51:20260730-175900

@groeneai

Copy link
Copy Markdown
Collaborator Author
Pre-PR validation gate (click to expand)
# Question Answer
a Deterministic repro? Yes, 100%. Hand-written v1.metadata.json declaring list/map/struct fields "required": false, then CREATE TABLE IF NOT EXISTS ... ENGINE = IcebergLocal(dir, 'Avro') + one INSERT. The written file's embedded avro.schema shows a bare array/map/record every run. Not a randomized flake.
b Root cause explained? Yes. AvroSerializer::createSchemaWithSerializeFn builds an avro::UnionSchema in exactly two arms, Nullable and Variant; Array/Tuple/Map build bare container schemas, so Avro nullability came only from the type carrying a Nullable wrapper. IcebergSchemaProcessor::getFieldType calls makeNullable only on its scalar branch, while the complex branch returns a bare Array/Map/Tuple regardless of that field's required bit. So an optional container reaches the writer without a Nullable, and is serialized as required.
c Fix matches root cause? Yes. The optionality bit is unrepresentable in the ClickHouse type, so the fix reads it from the authoritative source (the per-path Iceberg metadata #111775 introduced) at the field boundary. Not a band-aid: no widened bound, no data reduction, no no-random-* tag. The reported alternative "reject Iceberg Avro writes" was declined as a regression for users writing scalar-optional or required-complex schemas today.
d Test intent preserved / new tests added? Yes. New parallel-safe 04653_iceberg_avro_optional_complex_union.sh asserts per-field nullability read out of the written file's own schema, with required containers as over-fire controls, plus an optional-container read-back cell and a required-container control for it. Every assertion is proven load-bearing by a mutation (see row e). No existing test weakened; 03916_iceberg_avro_row_number_crash and 04092_iceberg_update_low_cardinality are unchanged and green 50/50.
e Both directions demonstrated? Yes, and per call site rather than only whole-diff, on binaries whose SELECT lower(buildId()) was asserted against the ELF Build ID before every measurement. Reverting AvroRowOutputFormat.{cpp,h} to master reddens the test; with the fix it passes. Beyond that, reverting each of the four swapped sites individually (four separate builds) moves a disjoint line set: top-level moves opt_list/opt_map/opt_struct and the read-back cell, array-element moves list_opt_struct_elem.element, tuple-field moves struct_opt_list_field.inner, map-value moves map_opt_struct_val.value. Two further mutations: not descending through the union in setIcebergFieldIds drops four nested-id lines, and removing the input_format_null_as_default pin reddens the compatibility='20.1' arm with the exact union message. Restoring the fix returns the test to green with the source md5s byte-identical.
f Fix is general across code paths? Yes. One shared boundary helper covers all four path-owning sites (top-level column, tuple field, array element, map value), verified by a scan that labels every call site by its case arm: wrapper at 4 sites, raw helper at the 3 transparent same-path recursions (Nullable, LowCardinality, Variant). An optional element/value nested inside a required container is also correctly wrapped. Map keys deliberately excluded (they bypass the helper, matching the spec forcing a map key required). Sibling writers: ORC done in #111775; Parquet uses FieldRepetitionType and is tracked separately, one concern per PR. Compaction and mutation rewrite paths both build the mapper via createColumnMapper, so they are covered automatically.
g Fix generalizes across inputs (params/datatypes/wrappers)? Yes. A 13-column matrix covers optional and required list/map/struct, optional scalar, optional element/value inside required containers, a nested optional struct field, and one optional complex payload per nested owner position (Array(Tuple) element, Tuple field of list type, Map value of struct type) so that each call site is exercised by a case only it can produce. Nullable(Tuple) (the double-wrap case) yields a single ["null", record]. Variant/Geometry and LowCardinality(Nullable(T)) are already unions, so the root-type test skips them. Scalar residual proven empty: every type IcebergSchemaProcessor::getSimpleType can produce is nullable-capable except Geometry, which is a Variant and hence already a union. The oracle itself is strict: a union must be exactly the 2-branch null-first form, so a wrong arity or swapped branch order fails rather than reading as optional.
h Backward compatible? Yes, with the read consequence stated in scope. No new setting and no default change, so no SettingsChangesHistory.cpp entry is required; only the Iceberg write path changes, gated on metadata that only Iceberg writes populate; plain FORMAT Avro output is byte-identical (compared byte-for-byte); the reader is untouched and files written before this change stay readable. The one behaviour change is on newly written files: at the default input_format_null_as_default = 1 such a file reads back unchanged, but with the setting off the read throws Cannot insert Avro Union(Null, array) into non-nullable type Array(Int32), because Array and Map cannot be Nullable in ClickHouse. Master wrote a bare container, which read at either setting value, so for a ClickHouse-written table this is works to hard error rather than purely pre-existing behaviour. That regime is exercised in the test rather than only described: 20/20 green under compatibility='20.1', whose pre-21.1 default for that setting is false, and removing the pin reddens it with exactly that message. Optional element/value/field positions are unaffected, their targets being Nullable. Fixing the reader is deliberately a separate concern.
i Invariants and contracts preserved? Yes. The helper decorates an already-built schema and changes no container logic. The "union emitted exactly once per path" invariant is enforced structurally by the AVRO_UNION/AVRO_NULL test rather than by threaded state, and removing that guard is confirmed by mutation to break the write: avro::UnionSchema::addType rejects a union branch at contrib/avro/lang/c++/impl/Schema.cc:107, which reaches the client as Code: 1001 std::exception (the avro::Exception message itself is not preserved, so the guard is what keeps this from being a bare unexplained failure). Encoder contract respected: the union index precedes the body, and index 0 is unreachable because the column at such a path is not Nullable. All 13 Iceberg field ids are byte-identical before and after. No new allocation, lock or error path.

Session id: cron:clickhouse-impl-slot-42:20260730-164200

@groeneai

Copy link
Copy Markdown
Collaborator Author

cc @al13n321 @scanhex12, could you review this? The Avro writer built a ["null", T] union only from a Nullable type wrapper, but the Iceberg read layer never wraps a list/map/struct in Nullable, so an optional container was serialized as required; this reads the optionality from the per-path metadata #111775 added, at the four sites that own a field.

@alexey-milovidov alexey-milovidov added the can be tested Allows running workflows for external contributors label Jul 30, 2026
@clickhouse-gh

clickhouse-gh Bot commented Jul 30, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [a4f09bf]

Summary: ✅


AI Review

Summary

This PR fixes the Iceberg Avro writer so optional complex fields (list, map, struct) are emitted as Avro null unions instead of bare required containers. The writer-side change is consistent with the Iceberg path metadata and the new test exercises the four field-owning call sites, but it also introduces a persisted self-read regression for Iceberg* tables whose stored format settings have input_format_null_as_default = 0.

Findings

❌ Blockers

  • [src/Processors/Formats/Impl/AvroRowOutputFormat.cpp:529] Wrapping every optional complex field in ["null", T] makes Avro files spec-compliant, but IcebergSchemaProcessor::getFieldType still exposes those fields to ClickHouse as bare non-nullable Array / Map / Tuple values, and AvroRowInputFormat still throws on Union(Null, T) when input_format_null_as_default is off. Because Iceberg* tables persist format settings from CREATE TABLE, a table created under old compatibility or with SETTINGS input_format_null_as_default = 0 will start writing files it can no longer read itself after this patch. The minimum safe fix is to either make the reader accept these unions for persisted Iceberg complex fields, or reject Avro writes when the stored setting combination would make the generated file unreadable.
Final Verdict

Status: ❌ Block

Minimum required action: avoid the new self-incompatible Iceberg* Avro state when persisted input_format_null_as_default = 0 is in effect, either by fixing the read path in the same change or by refusing the write with a clear exception.

@clickhouse-gh clickhouse-gh Bot added the pr-bugfix Pull request with bugfix, not backported by default label Jul 30, 2026
if (schema_type == avro::AVRO_UNION || schema_type == avro::AVRO_NULL)
return mapping;

avro::UnionSchema union_schema;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This fixes the Avro schema, but it also makes Iceberg* tables created with persisted input_format_null_as_default = 0 start writing files they cannot read themselves back.

IcebergSchemaProcessor::getFieldType still materializes optional complex fields as bare Array / Map / Tuple (src/Storages/ObjectStorage/DataLakes/Iceberg/SchemaProcessor.cpp:553-623), and the Avro reader still throws on any Union(Null, T) read into a non-nullable target when null_as_default is off (src/Processors/Formats/Impl/AvroRowInputFormat.cpp:492-534). Because object-storage tables persist format settings from CREATE TABLE (src/Storages/ObjectStorage/registerStorageObjectStorage.cpp:55-70), this is a stored regression rather than a session-only quirk: an existing IcebergLocal(..., 'Avro') table created under old compatibility or with SETTINGS input_format_null_as_default = 0 used to write/read its own optional list / map / struct columns, but after this change it will emit ["null", T] and then fail on read.

Can we either fix the reader in the same PR, or at least reject Avro writes for that persisted setting combination instead of silently producing unreadable data?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verified all three citations and they hold, so I agree the finding is real. I also found my own scope claim was wrong, and I have corrected the description.

I had written that ClickHouse DDL cannot author an optional container, because getIcebergType publishes required: true for Array/Map/Tuple. That misses the Nullable arm (Utils.cpp:627-631), which publishes required: false, and DataTypeTuple::canBeInsideNullable() is true. So Nullable(Tuple) is a ClickHouse-authored carrier. On a debug build, comparing this branch against its merge base with only AvroRowOutputFormat.{cpp,h} reverted:

written schema for a Nullable(Tuple(y Int64)) column master this branch
nt record ["null", "record"]
SELECT *, input_format_null_as_default = 1 (default) ok ok
SELECT *, setting persisted off at CREATE ok Code: 36

The union does not come from my guard being bypassed. The sink serializes the Iceberg-derived type (IcebergWrites.cpp:951), so the writer receives a bare Tuple even though system.columns reports Nullable(Tuple(y Int64)); the pre-existing Nullable arm never fires, my wrapper sees a record, and the reader's target is still bare. Exposure needs enable_nullable_tuple_type = 1 (default 0) plus that column type plus the setting persisted off, and it is a loud error rather than silent corruption.

On your two options I am taking neither in this PR, for one reason: getFieldType returning a bare container is also, on unmodified master, silent data loss. A genuine NULL in that column reads back as (0) with IS NULL false, identically on both arms. Rejecting the write would leave that untouched, and fixing the reader here would mean choosing a representation for an optional Array/Map, whose targets cannot be Nullable at all, so those stay unreadable at = 0 by construction on master today. That is a different change from emitting the spec-correct marker, so a fix task is created for the derivation, covering both the NULL loss and the = 0 readability, and this PR now discloses the narrowed regression window explicitly.

@clickhouse-gh

clickhouse-gh Bot commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

LLVM Coverage Report

Metric Baseline Current Δ
Lines 86.50% 86.50% +0.00%
Functions 91.90% 91.90% +0.00%
Branches 78.60% 78.60% +0.00%

Changed lines: Changed C/C++ lines covered: 33/34 (97.06%) · Uncovered code

Full report · Diff report

@PedroTadim PedroTadim self-assigned this Jul 31, 2026
@PedroTadim
PedroTadim added this pull request to the merge queue Jul 31, 2026
Merged via the queue into ClickHouse:master with commit b6fff36 Jul 31, 2026
178 checks passed
@robot-ch-test-poll4 robot-ch-test-poll4 added the pr-synced-to-cloud The PR is synced to the cloud repo label Jul 31, 2026
@groeneai

Copy link
Copy Markdown
Collaborator Author

Follow-up on the reader-derivation root cause this PR's description defers ("The reader derivation is the root cause and is tracked separately"). I investigated it and I am stopping short of a PR, because the fix turns out to need a design decision that is yours, not mine.

One root site. IcebergSchemaProcessor::getFieldType (SchemaProcessor.cpp:615) returns getComplexTypeFromObject(...) before the required || !canBeInsideNullable() ? t : makeNullable(t) branch on :622, so only leaf scalars ever consult the Iceberg required bit. A complex field is always derived bare.

Four measured consequences, all on unmodified master (604017b7), all from plain CREATE+INSERT with enable_nullable_tuple_type=1 and allow_experimental_insert_into_iceberg=1:

declared column inserted read back
Nullable(Tuple(y Int64)) NULL (0), IS NULL = 0
Tuple(inner Nullable(Tuple(y Int64))) tuple(NULL) ((0)), IS NULL = 0
Map(String, Nullable(Tuple(y Int64))) map('k', NULL) {'k':(0)}
Array(Nullable(Tuple(y Int64))) [tuple(1), NULL] Code: 349 CANNOT_INSERT_NULL_IN_ORDINARY_COLUMN

The Iceberg metadata is written correctly in every case (required: false, element-required: false); it is the ClickHouse-type re-derivation that drops the information. system.columns shows the declared Nullable(Tuple) until the first INSERT, then bare Tuple. The NULL is destroyed at write time: the Avro file carries ["null", record], but every row encodes union branch 1, so a NULL becomes y=0 on disk and no read-side change can recover it.

Why I am asking instead of pushing. Three sound fixes exist with different compatibility consequences, and picking one decides how far Nullable(Tuple) propagates through Iceberg schema mapping:

  1. Derive Nullable(Tuple) at every representable struct edge. Fixes all four rows. Requires nullable-awareness in schema-evolution type descent and value traversal (ComplexTypeSchemaProcessorFunctions.cpp:223-241,354-386 currently use unchecked static_pointer_cast at every edge and throw on a nested Null), and changes derived types in existing test references.
  2. Keep containers bare and reject the un-representable declaration at CREATE instead of losing data silently. Smaller, no representation change, but Nullable(Tuple) on Iceberg stops being expressible.
  3. A different optional-container representation. Also what an optional list/map needs: those cannot be Nullable at all, so an externally written one is unreadable at input_format_null_as_default=0.

I tried restricting to the top level only, which is why I am not proposing it: the nested rows above are the same defect, so pinning them as expected behaviour would be wrong.

I lean toward 2 if you want this small and safe, or 1 if Nullable(Tuple) should be fully supported here. BigQuery already chose the 1-shaped answer (BigQuerySchema.cpp:157-159, "so NULL records round-trip losslessly"), which is the precedent for the mechanism.

Which do you want? I will implement whichever you pick. Note files already written keep the corrupted payload either way.

@ alesapin @ scanhex12

@groeneai

Copy link
Copy Markdown
Collaborator Author

Hi @alesapin @scanhex12, gentle ping on the design question above (#112648 (comment)): it never reached you, because the handles there were written with a space and so notified nobody. Which of the three options do you want for optional complex fields in the Iceberg writer - derive Nullable(Tuple) at every representable struct edge, or reject the un-representable declaration at CREATE, or a different optional-container representation? I will implement whichever you pick.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

can be tested Allows running workflows for external contributors pr-bugfix Pull request with bugfix, not backported by default pr-synced-to-cloud The PR is synced to the cloud repo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants