Skip to content

[Variant] VariantArray::data_type returns StructType, causing Array::as_struct to panic #8319

@scovich

Description

@scovich

Describe the bug

arrow-rs normally has a 1:1 relationship between data types and array types, in order to allow downcasting from &dyn Array or ArrayRef. But VariantArray breaks that convention by declaring it is a StructType.

To Reproduce

A match of the form:

match array.data_type() {
      ...
    StructType(_) => array.as_struct().do_something(), // panics!
      ...
}

Expected behavior

Somehow we need a safe way to distinguish a VariantArray from a normal StructArray. Not just to protect hapless uses, but also to make our own code safe (cast_to_variant would both panic if passed a VariantArray today).

Additional context

Discovered during pathfinding work for variant shredding and a potential extension type for variant.

Metadata

Metadata

Assignees

Labels

bugparquetChanges to the parquet crateparquet-variantparquet-variant* crates

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions