Skip to content

feat(avro): apply column default values when reading missing fields#800

Open
huan233usc wants to merge 2 commits into
apache:mainfrom
huan233usc:feat/default-values-read-avro
Open

feat(avro): apply column default values when reading missing fields#800
huan233usc wants to merge 2 commits into
apache:mainfrom
huan233usc:feat/default-values-read-avro

Conversation

@huan233usc

@huan233usc huan233usc commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

What

Part 3 of 4 of Iceberg v3 column default-value support (POC #731), built on the
schema layer (#746) and the Parquet read path (#792).

When a column is present in the read (table) schema but absent from an Avro data
file — because the column was added after those rows were written — fill it with
the column's v3 initial-default instead of null.

Changes

  • Avro projection (avro_schema_util.cc): when a field is missing from the
    file and carries an initial-default, project it as
    FieldProjection::Kind::kDefault, mirroring the generic / Parquet paths.
  • Avro decode (avro_data_util.cc, avro_direct_decoder.cc): materialize
    the kDefault branch through an Avro-local AppendDefaultToBuilder helper.
    It reuses the shared ToArrowScalar conversion, while keeping Avro's
    row-by-row ArrayBuilder append behavior out of the shared Arrow utility.

Tests

  • avro_data_test: AppendDefaultToBuilder appends a value and casts to the
    builder type; AppendDatumToBuilder fills missing required and optional
    default fields.
  • avro_test: end-to-end — write an Avro file with an old schema, then read it
    through ReaderFactoryRegistry with an evolved schema carrying defaults
    (ReadMissingFieldsWithDefaults).

Stack

  1. feat(schema): represent, serialize and validate v3 column default values (1/4) #746 — schema: represent / serialize / validate (merged)
  2. feat(parquet): apply column default values when reading missing fields (2/4) #792 — read path: Parquet (merged)
  3. this PR — read path: Avro
  4. schema evolution: addColumn / updateColumnDefault (feat: support v3 column default values in UpdateSchema (3/4) #793)

Draft while the earlier PRs in the stack settle.

@huan233usc
huan233usc force-pushed the feat/default-values-read-avro branch from 75bd63f to 950f4dc Compare July 12, 2026 21:10
@huan233usc huan233usc changed the title feat(avro): apply column default values when reading missing fields (3/4) feat(avro): apply column default values when reading missing fields Jul 20, 2026
…3/4)

When a column is present in the read schema but missing from an Avro data file
(written before the column existed), fill it with the column's v3
initial-default instead of null. Reuses the shared arrow/literal_util
materializer (merged in apache#792) and adds AppendDefaultToBuilder for the row-by-row
Avro decode paths, plus a kDefault projection branch in the Avro schema/data
projection.

Part 3 of the v3 column-default-values work (POC apache#731), built on the schema
support in apache#746 and the Parquet read path in apache#792.
Row-oriented Avro decode needs per-builder appends, while Parquet uses
batch MakeDefaultArray. Share ToArrowScalar only; don't put the Avro
shape into the shared arrow literal util.
@huan233usc
huan233usc force-pushed the feat/default-values-read-avro branch from 0961b90 to 9e1605f Compare July 20, 2026 04:38
@huan233usc
huan233usc marked this pull request as ready for review July 20, 2026 04:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant