Skip to content

feat(arrow): read unshredded variant columns#2880

Open
c-thiel wants to merge 1 commit into
apache:mainfrom
c-thiel:feat/variant-parquet-read
Open

feat(arrow): read unshredded variant columns#2880
c-thiel wants to merge 1 commit into
apache:mainfrom
c-thiel:feat/variant-parquet-read

Conversation

@c-thiel

@c-thiel c-thiel commented Jul 23, 2026

Copy link
Copy Markdown
Collaborator

What changes are included in this PR?

Project variant columns on read by mapping their metadata/value leaves (which carry no field id — only the enclosing group does) to the variant's field id, mirroring Java's PruneColumns: the whole group is projected with no type-promotion check. Shredded variants (typed_value present) are rejected until we can reconstruct them.

collect_variant_leaves numbers leaves exactly like Fields::filter_leaves, including its Dictionary/RunEndEncoded unwrapping and Union descent, so a sibling of those kinds can't shift a variant's leaves onto the wrong column. The pruned schema used for the type-promotion check includes variant leaves too, keeping map<_, variant> a well-formed two-field map.

Variant identity is recovered from the Iceberg schema: fields the table schema declares as variants are tagged with the arrow.parquet.variant extension so arrow_schema_to_schema folds the storage struct back into Type::Variant. This mirrors iceberg-java's TypeWithSchemaVisitor, which recognizes a variant by the Parquet annotation OR the Iceberg type, and avoids depending on the Parquet variant annotation being present.

Are these changes tested?

yes


Based on #2188 and #2840 and

Project variant columns on read by mapping their metadata/value leaves
(which carry no field id — only the enclosing group does) to the variant's
field id, mirroring Java's PruneColumns: the whole group is projected with
no type-promotion check. Shredded variants (typed_value present) are
rejected until we can reconstruct them.

collect_variant_leaves numbers leaves exactly like Fields::filter_leaves,
including its Dictionary/RunEndEncoded unwrapping and Union descent, so a
sibling of those kinds can't shift a variant's leaves onto the wrong
column. The pruned schema used for the type-promotion check includes
variant leaves too, keeping map<_, variant> a well-formed two-field map.

Variant identity is recovered from the Iceberg schema: fields the table
schema declares as variants are tagged with the arrow.parquet.variant
extension so arrow_schema_to_schema folds the storage struct back into
Type::Variant. This mirrors iceberg-java's TypeWithSchemaVisitor, which
recognizes a variant by the Parquet annotation OR the Iceberg type, and
avoids depending on the Parquet variant annotation being present.
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