Skip to content

[Variant] Accept Dictionary and RunEndEncoded metadata in VariantArray #10802

Closed

Description

@peterxcli

Describe the bug

The canonical arrow.parquet.variant extension permits its non-nullable metadata child to be dictionary-encoded or run-end-encoded. However, VariantArray::try_new calls a validator whose validation and row access accept only Binary, LargeBinary, and BinaryView.

This affects arrow-rs 59.2.0 and current main:

This is specifically about encoding the Variant metadata child. It is not about shredded typed_value layouts or Dictionary/REE output from variant_to_arrow (#10013 / #10014).

To Reproduce

A conforming StructArray with this storage schema fails construction:

Struct<
  metadata: Dictionary<Int8, Binary> not null,
  value: Binary not null
>

For example, using an empty Variant metadata dictionary and an Int8 Variant value:

let metadata_values = Arc::new(BinaryArray::from(vec![
    Some(&[0x01, 0x00, 0x00][..]),
]));
let metadata = Arc::new(
    DictionaryArray::<Int8Type>::try_new(
        Int8Array::from(vec![0]),
        metadata_values,
    )
    .unwrap(),
);
let value = Arc::new(BinaryArray::from(vec![Some(&[12, 1][..])]));

let array = StructArray::try_new(
    Fields::from(vec![
        Field::new("metadata", metadata.data_type().clone(), false),
        Field::new("value", DataType::Binary, false),
    ]),
    vec![metadata, value],
    None,
)
.unwrap();

VariantArray::try_new(&array).unwrap();

The final call currently fails with:

VariantArray 'metadata' field must be Binary, LargeBinary, or BinaryView, got Dictionary(Int8, Binary)

Run-end-encoded metadata is rejected for the same reason.

Expected behavior

VariantArray should accept Dictionary- and RunEndEncoded metadata whose logical values are Binary, LargeBinary, or BinaryView.

All paths that consume metadata bytes—including row access and compute paths such as variant_get and unshred_variant—must resolve the logical metadata value correctly; relaxing constructor validation alone would not be sufficient.

Please add focused coverage for both Dictionary and RunEndEncoded metadata, including null/sliced arrays and at least one downstream compute path.

Additional context

Downstream consumers currently have to decode the metadata child eagerly before constructing VariantArray. This is a follow-up to the raw binary layout support in #8387 / #9610.

Activity

  1. added theissue type on Aug 23, 2026
  2. peterxcli commented on Aug 23, 2026

    @peterxcli
    MemberAuthor

    take

  3. added 2 commits that reference this issue on Aug 28, 2026
    9500647
    1650afb
  4. added 3 commits that reference this issue on Sep 18, 2026
    bce3835
    c567d35
    d111538
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions