Skip to content

feat(arrow-avro): accept default value of null for Avro union with null type in any branch position#9487

Draft
mzabaluev wants to merge 3 commits intoapache:mainfrom
mzabaluev:default-null-for-union-with-null-second
Draft

feat(arrow-avro): accept default value of null for Avro union with null type in any branch position#9487
mzabaluev wants to merge 3 commits intoapache:mainfrom
mzabaluev:default-null-for-union-with-null-second

Conversation

@mzabaluev
Copy link
Contributor

@mzabaluev mzabaluev commented Feb 27, 2026

Which issue does this PR close?

Rationale for this change

The Avro specification version 1.12 extends acceptance of default values for unions to match any schema branch in the union rather than the first.

This change implements the new behavior in the specific case of the default value being null, which is important for some real-world cases of Iceberg schema evolution. Spark converts nullable fields in its SQL schema to Avro field types with the null variant listed last. When a column is added to an iceberg table backed by Avro files, the default value of its field in the reader schema shall be specified as null.

What changes are included in this PR?

Change the case verification of null default value for union and nullable types to allow null in any branch (for unions treated as Arrow unions) and nullability order (for unions treated as nullable types).

Are these changes tested?

Added a column in test_schema_resolution_defaults_all_supported_types to exercise the ["int", "null"] type with the default of null.

Are there any user-facing changes?

This is a behavioral change where more schema resolution cases become accepted than were permitted by the Avro 1.11 spec.

Test the Avro 1.12 spec behavior of resolving default values
in the specific case when the default value for the field added in
the reader schema is null, and null the second branch in the field's
union type.
@github-actions github-actions bot added arrow Changes to the arrow crate arrow-avro arrow-avro crate labels Feb 27, 2026
@mzabaluev
Copy link
Contributor Author

Created as a draft for the time being because the changes are not yet feature-gated as planned per #8703.

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

Labels

arrow Changes to the arrow crate arrow-avro arrow-avro crate

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant