[Variant] Add variant docs and examples#7661
Merged
alamb merged 6 commits intoapache:mainfrom Jun 19, 2025
Merged
Conversation
Contributor
Author
|
FYI @mkarbo @superserious-dev @scovich and @PinkCrow007 |
alamb
commented
Jun 13, 2025
This was referenced Jun 13, 2025
alamb
added a commit
that referenced
this pull request
Jun 16, 2025
# Which issue does this PR close? - Part of #6736 # Rationale for this change While making documentation / examples for working with `Variant` in #7661, I found it was somewhat awkward to make `Variant` values directly from the metadata and value. Specifically you have to ```rust let metadata = [0x01, 0x00, 0x00]; let value = [0x09, 0x48, 0x49]; // parse the header metadata let metadata = VariantMetadata::try_new(&metadata).unwrap(); // and only then can you make the Variant Variant::try_new(&metadata, &value).unwrap() ``` I would really like to be able to create `Variant `directly from `metadata` and `value` without having to make a `VariantMetadata` structure # What changes are included in this PR? This PR proposes a small change to the API so creating a Variant now looks like: ```rust let metadata = [0x01, 0x00, 0x00]; let value = [0x09, 0x48, 0x49]; // You can now make the Variant directly from the metadata and value Variant::try_new(&metadata, &value).unwrap() ``` # Are there any user-facing changes? Yes, the API for creating APIs is slightly different (and I think better)
Contributor
Author
|
I am quite pleased with how this looks now |
Contributor
Author
|
@scovich @PinkCrow007 or @mkarbo , might I trouble one of you for a review of this PR (no code, just docs)? |
scovich
approved these changes
Jun 18, 2025
mkarbo
approved these changes
Jun 18, 2025
| /// | ||
| /// When stored in Parquet files, Variant fields can also be *shredded*. Shredding | ||
| /// refers to extracting some elements of the variant into separate columns for | ||
| /// more efficient extraction/filter pushdown. The [Variant Shredding |
Contributor
Author
Co-authored-by: Ryan Johnson <scovich@users.noreply.github.com>
Contributor
Author
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.

Which issue does this PR close?
We generally require a GitHub issue to be filed for all bug fixes and enhancements and this helps us generate change logs for our releases. You can link an issue to this PR using the GitHub syntax.
Rationale for this change
Using the parquet APIs came up in #7644 (comment) so I wanted to help contribute some additional documentation / tests
What changes are included in this PR?
Add documentation and tests about
Variant, specifically some examples of how to createVariantvaluesAre there any user-facing changes?
More docs