feat(variant): allow creating VariantArray from Option items convertible to Variant - #11053
Open
jabrailkhalil wants to merge 1 commit into
Open
feat(variant): allow creating VariantArray from Option items convertible to Variant#11053jabrailkhalil wants to merge 1 commit into
jabrailkhalil wants to merge 1 commit into
Conversation
…ble to Variant Generalize FromIterator<Option<Variant>> for VariantArray to FromIterator<Option<V>> where V: Into<Variant>, so values that convert cleanly to Variant (e.g. i64, &str) can be collected directly. Adds regression tests for i64 and str items, including null rows and short vs long string storage.
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.
Rationale
Closes #8628.
Previously
VariantArraycould be collected only fromOption<Variant>items:With this change, any type that converts cleanly into
Variantcan be collected directly:This follows the suggestion made in #8625 (comment).
Changes
parquet-variant-compute/src/variant_array.rs: generalizeFromIterator<Option<Variant<'m, 'v>>>toimpl<'m, 'v, V: Into<Variant<'m, 'v>>> FromIterator<Option<V>>, converting each item throughInto::into. Existing code that collectsOption<Variant>items keeps working (identityInto).i64items with nulls,&stritems covering both short-string (ShortString) and long-string (String) storage.Verification
cargo test -p parquet-variant-compute --lib— 366 tests passed (364 existing + 2 new), including the newtest_from_option_into_variants_into_variant_arrayandtest_from_option_str_into_variant_array.cargo clippy -p parquet-variant-compute --all-targets -- -D warnings— clean.cargo fmt --all -- --check— clean.Note: local verification used the
x86_64-pc-windows-gnutarget; upstream CI covers the full matrix.AI disclosure
Per the Arrow project's AI-generated submissions guidance: this change was implemented with the assistance of an AI coding agent. The author reviewed the final diff, verified it compiles and passes tests/clippy/fmt locally, and takes full ownership of the change.
The ASF ICLA may need to be on file before merge (asf-clabot will report the status).