feat(arrow): read unshredded variant columns#2880
Open
c-thiel wants to merge 1 commit into
Open
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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