Skip to content

Conversation

alamb
Copy link
Contributor

@alamb alamb commented Aug 13, 2025

Which issue does this PR close?

Rationale for this change

TLDR is we need a way to test and work out how Variant integration with the actual parquet reader/writer will look, so let's do it in the parquet crate.

Please see the essay on #8132 for background

Follow on tasks (I will file tickets for these items if we agree on this as an integration mechanism):

Follow up tasks that came out of this PR but do not depend on it

What changes are included in this PR?

  1. Add the variant_experimental feature to the parquet crate
  2. Publicly export the variant crates
  3. Add docs and examples

Are these changes tested?

Yes by new CI

Are there any user-facing changes?

This adds a new feature flag, and new

@github-actions github-actions bot added parquet Changes to the parquet crate parquet-variant parquet-variant* crates labels Aug 13, 2025
@alamb alamb changed the title Add variant feature to parquet crate Path Finding: Add variant feature to parquet crate Aug 14, 2025
@alamb alamb force-pushed the alamb/variant-feature branch from ed04fb5 to 7ab46a1 Compare August 14, 2025 18:27
@alamb alamb changed the title Path Finding: Add variant feature to parquet crate Path Finding: Add variant_experimental feature to parquet crate Aug 14, 2025
@alamb alamb changed the title Path Finding: Add variant_experimental feature to parquet crate Add variant_experimental feature to parquet crate Aug 14, 2025
@alamb alamb marked this pull request as ready for review August 14, 2025 18:46
@alamb alamb marked this pull request as draft August 14, 2025 18:47
@alamb alamb force-pushed the alamb/variant-feature branch from 7ab46a1 to 0ec7656 Compare August 14, 2025 18:48
@github-actions github-actions bot removed the parquet-variant parquet-variant* crates label Aug 14, 2025
@alamb alamb force-pushed the alamb/variant-feature branch from 0ec7656 to be5cf31 Compare August 14, 2025 18:52
//! [`VariantArray`]: compute::VariantArray
//! [`variant_get`]: compute::variant_get
//!
//! # Example: Writing a Parquet file with Variant column
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Being able to write this example is the largest rationale in my mind for the feature flag in the parquet crate

//! variant_builder.finish();
//! let array = builder.build();
//!
//! // TODO support writing VariantArray directly
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I will file a follow on ticket for this problem

//! let batch = RecordBatch::try_from_iter(vec![("data", array)])?;
//!
//! // write the RecordBatch to a Parquet file
//! let file = std::fs::File::create("variant-json.parquet")?;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is kind of neat to see the data written. I looked at the resulting file using datafusion-cli and it looks like like this (note it does not have the parquet logical annotation on it)

> select * from 'parquet/variant-json.parquet';
+-----------------------------------------------------------------------------------------------------------------------------------+
| data                                                                                                                              |
+-----------------------------------------------------------------------------------------------------------------------------------+
| {metadata: 11020003076167656e616d65, value: 020200010002080c1e15416c696365}                                                       |
| {metadata: 010400040b0e1263697479616464726573736167656e616d65, value: 0203010203000e10140201000009214e657720596f726b0c190d426f62} |
| {metadata: 010000, value: 020000}                                                                                                 |
| {metadata: 010000, value: 020000}                                                                                                 |
+-----------------------------------------------------------------------------------------------------------------------------------+
4 row(s) fetched.
Elapsed 0.003 seconds.

@alamb
Copy link
Contributor Author

alamb commented Aug 14, 2025

I would like to know if there are any objections to this approach from other maintainers such as @Dandandan @etseidl @waynexia @tustvold and @mbrobbel

Also, other Variant contributors like @carpecodeum @scovich @mprammer @klion26 @friendlymatthew please provide any feedback if you have it

@etseidl
Copy link
Contributor

etseidl commented Aug 14, 2025

No objections from me.

@friendlymatthew
Copy link
Contributor

Very exciting. Thank you!

@klion26
Copy link
Member

klion26 commented Aug 15, 2025

Thank you for pushing this forward!

@alamb
Copy link
Contributor Author

alamb commented Aug 19, 2025

I am hoping we can merge this after I made the RC for the next release (ideally in the next day or two)

@mbrobbel mbrobbel merged commit d9a4b39 into apache:main Sep 8, 2025
33 checks passed
@mbrobbel
Copy link
Member

mbrobbel commented Sep 8, 2025

Thanks @alamb

@alamb alamb deleted the alamb/variant-feature branch September 9, 2025 12:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
parquet Changes to the parquet crate
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Variant] Add variant feature to parquet crate
5 participants