Skip to content

[Variant] Move VariantType from parquet-variant-compute to parquet-variant - #12005

Merged
alamb merged 1 commit into
apache:mainfrom
sdf-jkl:variant-type-to-parquet-variant
Oct 30, 2026
Merged

alamb merged 1 commit into
apache:mainfrom
sdf-jkl:variant-type-to-parquet-variant

Conversation

@sdf-jkl

@sdf-jkl sdf-jkl commented Oct 30, 2026

Copy link
Copy Markdown
Member

Which issue does this PR close?

Rationale for this change

Using the arrow.parquet.variant extension type currently requires depending on parquet-variant-compute, which pulls in the full arrow crate and parquet-variant-json. Schema-only consumers such as datafusion-common and datafusion-expr (apache/datafusion#26822) only need the type itself, which depends on nothing beyond arrow-schema.

What changes are included in this PR?

VariantType moves unchanged from parquet-variant-compute/src/variant_array.rs to a new parquet-variant/src/extension.rs and is exported as parquet_variant::VariantType. parquet-variant-compute re-exports it, so parquet_variant_compute::VariantType and parquet::variant::VariantType keep working and refer to the same type.

Are these changes tested?

Yes. Existing uses through the old paths (the VariantArray doctests, variant_get, and the parquet Variant schema tests) are unchanged and still pass. A new unit test in parquet-variant covers the type on its own: a struct field accepts the extension and a non-struct field is rejected with the existing error message.

Are there any significant user-facing changes?

VariantType is now also available from parquet-variant. The existing import path is kept, so this is not a breaking change.

🤖 Generated with Claude Code

Schema-only consumers can now use the `arrow.parquet.variant` extension
type without depending on the compute kernels or JSON conversion.
`parquet-variant-compute` re-exports it, so the existing path keeps working.

Closes apache#11952.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@github-actions github-actions Bot added parquet-variant parquet-variant* crates enhancement New feature/addition labels Oct 30, 2026
@sdf-jkl
sdf-jkl marked this pull request as ready for review October 30, 2026 20:18
@sdf-jkl

sdf-jkl commented Oct 30, 2026

Copy link
Copy Markdown
Member Author

@alamb @Rich-T-kid @Jefffrey PTAL

@alamb alamb left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good -- thank you @sdf-jkl

I verified not a breaking API

mod variant_to_arrow;

pub use variant_array::{ShreddingState, VariantArray, VariantArrayIter, VariantType};
pub use parquet_variant::VariantType;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

backwards compatbility pub use 👍

@alamb
alamb added this pull request to the merge queue Oct 30, 2026
@sdf-jkl

sdf-jkl commented Oct 30, 2026

Copy link
Copy Markdown
Member Author

Thanks @alamb 🎉

Merged via the queue into apache:main with commit bf0cde3 Oct 30, 2026
21 checks passed
@sdf-jkl
sdf-jkl deleted the variant-type-to-parquet-variant branch October 30, 2026 21:31
@sdf-jkl

sdf-jkl commented Oct 30, 2026

Copy link
Copy Markdown
Member Author

@alamb we moved it to parquet-variant just now to avoid pulling parquet-variant-compute to datafusion just to add the df ext type, but now I'm thinking wouldn't it be better to move it to arrow-schema/src/extension/canonical? This way there's no need to pull parquet-variant at all and the ext type itself doesn't seem to depend on anything in either variant crate.

@alamb

alamb commented Oct 31, 2026

Copy link
Copy Markdown
Contributor

It does appear to be a canonical extension type: https://arrow.apache.org/docs/format/CanonicalExtensions.html#parquet-variant

So I agree with idea of moving it

It would be good to do it before we release another version too

mbutrovich pushed a commit to mbutrovich/arrow-rs that referenced this pull request Nov 3, 2026
…ache#12033)

# Which issue does this PR close?

Follow-up to apache#12005; relates to apache#11952.

# Rationale for this change

Schema-only consumers still need `parquet-variant` to use `VariantType`,
and `Field::try_canonical_extension_type` does not recognize
`arrow.parquet.variant`. Hosting the descriptor alongside the other
canonical extensions lets these consumers use `arrow-schema` directly.

# What changes are included in this PR?

Move `VariantType` into `arrow-schema`'s canonical extensions and
register `CanonicalExtensionType::Variant`. Re-export the same type from
`parquet-variant`, preserving the existing compute and Parquet import
paths. Metadata handling and storage validation are unchanged; apache#11938
remains separate.

# Are these changes tested?

The moved unit test retains the existing storage-type checks and now
verifies canonical extension lookup. Existing Variant compute doctests
and Parquet Variant tests exercise the retained import paths.

# Are there any significant user-facing changes?

Existing imports remain compatible. Direct `arrow-schema` users need its
`canonical_extension_types` feature. `parquet-variant` now enables that
feature to retain its unconditional re-export, which also enables
`serde_core` and `serde_json` dependencies in `arrow-schema`.

Implementation and test changes prepared with Codex.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature/addition parquet-variant parquet-variant* crates

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Variant] Move VariantType from parquet-variant-compute to parquet-variant

2 participants