Mola-maker opened a new pull request, #12211:
URL: https://github.com/apache/arrow-rs/pull/12211
- Closes #11942
# Rationale for this change
`cast_to_variant` serialized nested Variant storage as ordinary objects: a
struct with a Variant-annotated child field `a` (value `1`) became
`{"a":{"metadata":"...","value":"..."}}` instead of `{"a":1}`. The row builders
dispatched only on `DataType`, so the `VariantType` extension on child fields
was dropped. The same applied to list, map, union and run-end-encoded children.
# What changes are included in this PR?
- A new `VariantArrowToVariantBuilder` that wraps the child in
`VariantArray::try_new` and copies rows with `try_value` (null rows stay null),
including rows stored as shredded `typed_value`s.
- A field-aware factory, `make_arrow_to_variant_row_builder_for_field`, that
selects the Variant builder when the child field has a valid `VariantType`
extension and otherwise falls back to the existing `DataType` dispatch.
- Wired into the struct, list-like, map, union and run-end-encoded builders,
which already have the child field. Dictionary values carry no field and are
unchanged, as are unannotated structs with `metadata`/`value` columns. The
public `cast_to_variant(&dyn Array)` signature is unchanged.
# Are these changes tested?
Yes. Six new tests in `parquet-variant-compute/src/cast_to_variant.rs`, one
per container (struct, list, map, union, run-end-encoded) plus a shredded
`typed_value` struct child, covering the issue's exact case, null children, and
the unannotated-struct-stays-an-object case. Full crate suite: 377 lib tests +
15 doc tests pass. `cargo fmt --check` and `cargo clippy -p
parquet-variant-compute --all-targets --all-features -- -D warnings` are clean.
# Are there any significant user-facing changes?
Behavior fix only: nested Variant values are now preserved instead of being
serialized as objects. No public API change.
# AI usage disclosure
AI assistance was used to implement the fix and tests, following the
approach sketched in #11942; the changes were verified with the crate's test
suite, clippy and fmt.
--
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]