Skip to content

FixedSizeBinaryArray::new_null Does Not Properly Set the Length of the Values Buffer #8900

@tschwarzinger

Description

@tschwarzinger

Describe the bug

The function FixedSizeBinaryArray::new_null aims to create a new FixedSizeBinaryArray with all null values. But instead of creating a MutableBuffer with the expected size, it creates a MutableBuffer with the expected capacity, leaving the length of the buffer 0.

As the fixed size binary array is a fixed size primitive array I'd expect the values to buffer to have at least len * value_len bytes. This is not the case as the resulting buffer will have a length of zero (even though the capacity would be there).

To Reproduce

let null_array = FixedSizeBinaryArray::new_null(4, 3);
assert_eq!(null_array.len(), 3);
assert_eq!(null_array.values().len(), 12);

null_array.values().len() return 0 instead of 12

Expected behavior

Actually allocate a buffer with the expected length, not just capacity.

Additional context

I stumbled across this while investigating apache/datafusion#18870

Metadata

Metadata

Assignees

No one assigned

    Labels

    arrowChanges to the arrow cratebug

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions