Skip to content

[Variant] Define basic convenience methods for variant pathing - #7894

Merged
alamb merged 1 commit into
apache:mainfrom
scovich:simple-variant-pathing
Jul 11, 2025
Merged

alamb merged 1 commit into
apache:mainfrom
scovich:simple-variant-pathing

Conversation

@scovich

@scovich scovich commented Jul 10, 2025

Copy link
Copy Markdown
Contributor

Which issue does this PR close?

Part of

Rationale for this change

An expected use case for variant pathing (e.g. a future variant_get) would be to request a field from a variant value that is expected to be an object, or an element from a variant value that is expected to be an array. Those methods are currently missing.

What changes are included in this PR?

Define Variant::get_object_field and Variant::get_array_element methods that do what they say (returning None if anything mismatches).

Are these changes tested?

New doc tests for the methods.

Are there any user-facing changes?

New public methods on Variant enum.

@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 great to me -- thank you @scovich

@alamb
alamb merged commit 7c42a83 into apache:main Jul 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

parquet parquet crate

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants