jabrailkhalil opened a new pull request, #11053:
URL: https://github.com/apache/arrow-rs/pull/11053
## Rationale
Closes #8628.
Previously `VariantArray` could be collected only from `Option<Variant>`
items:
```rust
let arr: VariantArray = values.iter().map(|v|
Some(Variant::from(*v))).collect();
```
With this change, any type that converts cleanly into `Variant` can be
collected directly:
```rust
let arr: VariantArray = vec![Some(1_i64), None,
Some(42_i64)].into_iter().collect();
let arr: VariantArray = vec![Some("hello"), Some("a very long string
exceeding the short string limit")].into_iter().collect();
```
This follows the suggestion made in
https://github.com/apache/arrow-rs/pull/8625#discussion_r2432827098.
## Changes
- `parquet-variant-compute/src/variant_array.rs`: generalize
`FromIterator<Option<Variant<'m, 'v>>>` to `impl<'m, 'v, V: Into<Variant<'m,
'v>>> FromIterator<Option<V>>`, converting each item through `Into::into`.
Existing code that collects `Option<Variant>` items keeps working (identity
`Into`).
- Added regression tests: `i64` items with nulls, `&str` items 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 new
`test_from_option_into_variants_into_variant_array` and
`test_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-gnu` target; 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).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]