Skip to content

arrow::compute::interleave fails with struct arrays with no fields #8533

@kawadakk

Description

@kawadakk

Describe the bug
arrow::compute::interleave returns an error after arrow-rs 56.0.0 if a struct array with no fields is provided.

To Reproduce
Add the following code to arrow-select/src/interleave.rs:

#[test]
fn test_struct_no_fields() {
    let fields = Fields::empty();
    let a = StructArray::try_new_with_length(fields.clone(), vec![], None, 10).unwrap();
    let v = interleave(&[&a], &[(0, 0)]).unwrap();
    assert_eq!(v.len(), 1);
    assert_eq!(v.data_type(), &DataType::Struct(fields));
}
thread 'interleave::tests::test_struct_no_fields' panicked at arrow-select/src/interleave.rs:744:46:
called `Result::unwrap()` on an `Err` value: InvalidArgumentError("use StructArray::try_new_with_length or StructArray::new_empty_fields to create a struct array with no fields so that the length can be set correctly")
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace


failures:
    interleave::tests::test_struct_no_fields

Expected behavior
Not panicking

Additional context

Metadata

Metadata

Assignees

No one assigned

    Labels

    arrowChanges to the arrow cratebug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions