feat(arrow): recognize arrow.parquet.variant on schema import#2840
Open
c-thiel wants to merge 1 commit into
Open
feat(arrow): recognize arrow.parquet.variant on schema import#2840c-thiel wants to merge 1 commit into
c-thiel wants to merge 1 commit into
Conversation
Teach arrow_schema_to_schema to fold a field tagged with the canonical arrow.parquet.variant extension into an atomic Type::Variant, the inverse of the export path added in apache#2188. Previously such a schema errored with "Field id not found in metadata" because the variant's metadata/value storage sub-fields carry no field id.
CTTY
reviewed
Jul 18, 2026
| fn variant(&mut self, field: &FieldRef) -> Result<Self::T> { | ||
| // The extension may only sit on struct storage (mirrors | ||
| // `VariantExtensionType::supports_data_type`). | ||
| if !matches!(field.data_type(), DataType::Struct(_)) { |
Collaborator
There was a problem hiding this comment.
Should we match the nested types here as well (metadata and value)?
| /// single logical variant. | ||
| /// | ||
| /// Takes the `&FieldRef` rather than a `&DataType` because the variant signal | ||
| /// lives on the field's metadata, not on its data type. |
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.
Teach arrow_schema_to_schema to fold a field tagged with the canonical arrow.parquet.variant extension into an atomic Type::Variant, the inverse of the export path added in #2188. Previously such a schema errored with "Field id not found in metadata" because the variant's metadata/value storage sub-fields carry no field id.
Which issue does this PR close?
PR 1 of 2 for Variant read support.
What changes are included in this PR?
Add a defaulted
ArrowSchemaVisitor::variantdispatched via a newvisit_fieldhelper at each field-dispatch site. The default re-enters normal traversal, so the reconstructing visitors (Int96Coercion, MetadataStrip) are unchanged;ArrowSchemaConverteroverrides it to fold the struct without descending, guarding that the extension sits on Struct storage. Mirrors Java's Parquet reader, which recovers a variant from its group-level annotation without visiting the group's children.Covers top-level, struct-nested, list-element and map-value positions plus auto-assigned ids; regenerates the iceberg public-api baseline.
Are these changes tested?
unit-tested yes.