Skip to content

List of structures crashes on out of bounds cases if struct has null value #16187

Open
@comphead

Description

@comphead

Describe the bug

The query below crashes

> select map_values(map([named_struct('a', 1, 'b', null)], [named_struct('a', 1, 'b', null)]))[0] as a;

thread 'main' panicked at /Users/xxx/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/arrow-array-55.0.0/src/array/null_array.rs:149:9:
NullArray data should not contain a null buffer, as no buffers are required
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

UPD: the problem is more broad and impacts any list of struct if the struct contains a null

> select [named_struct('a', 1, 'b', null)][-2];

thread 'main' panicked at /Users/xxx/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/arrow-array-55.1.0/src/array/null_array.rs:149:9:
NullArray data should not contain a null buffer, as no buffers are required
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

The problem is the b field is a NullType, if it is casted to any other type the query returns NULL as expected

It is expected to handle this gracefully, if index is not found it should return NULL

To Reproduce

No response

Expected behavior

No response

Additional context

No response

Metadata

Metadata

Assignees

Labels

bugSomething isn't workinggood first issueGood for newcomers

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions