Skip to content

Support FixedSizedListArray for length kernel #4517

Description

@alamb

Is your feature request related to a problem or challenge? Please describe what you are trying to do.

While implement unnest in DataFusion for FixedSizeListArray (see apache/datafusion#6903) it turns out there is no support for FixedSizeListArray in the length kernel

https://docs.rs/arrow/latest/arrow/compute/kernels/length/fn.length.html

Describe the solution you'd like
While it sounds silly, I would like to Support FixedSizedListArray for length kernel

Specifically, it would be nice to get the NULLs handled correctly even though all the values will of course be the same (fixed!) size lenth

Here is a reproducer:

fn main() {
    // Construct a value array
    let value_data = ArrayData::builder(DataType::Int32)
        .len(9)
        .add_buffer(Buffer::from_slice_ref(&[0, 1, 2, 3, 4, 5, 6, 7, 8]))
        .build()
        .unwrap();
    let list_data_type = DataType::FixedSizeList(
        Arc::new(Field::new("item", DataType::Int32, false)),
        3,
    );
    let nulls = NullBuffer::from(vec![true, false, true]);
    let list_data = ArrayData::builder(list_data_type.clone())
        .len(3)
        .add_child_data(value_data.clone())
        .nulls(Some(nulls))
        .build()
        .unwrap();
    let list_array = FixedSizeListArray::from(list_data);


    let lengths = arrow::compute::kernels::length::length(&list_array).unwrap();
    println!("{}", pretty_format_columns("lengths", &[lengths]).unwrap());

}

It should print out [3, null, 3]

Describe alternatives you've considered

Additional context

Metadata

Metadata

Assignees

No one assigned

    Labels

    arrowChanges to the arrow crateenhancementAny new improvement worthy of a entry in the changeloggood first issueGood for newcomers

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions