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
Describe the bug
The function
FixedSizeBinaryArray::new_nullaims to create a newFixedSizeBinaryArraywith all null values. But instead of creating aMutableBufferwith the expected size, it creates aMutableBufferwith 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_lenbytes. This is not the case as the resulting buffer will have a length of zero (even though the capacity would be there).To Reproduce
null_array.values().len()return 0 instead of 12Expected behavior
Actually allocate a buffer with the expected length, not just capacity.
Additional context
I stumbled across this while investigating apache/datafusion#18870