Skip to content

Conversation

@tobixdev
Copy link
Contributor

@tobixdev tobixdev commented Nov 26, 2025

Which issue does this PR close?

Note that creating sch arrays was already possible with the builder API (see test_fixed_size_binary_builder_with_zero_value_length) but not directly with the Array API.

Rationale for this change

Avoid panicking (divide by zero) in FixedSizeBinaryArray::try_new(0, ...)

What changes are included in this PR?

Special case for size == 0 in FixedSizeBinaryArray::try_new.

Are these changes tested?

Yes, additional constructor tests.

Are there any user-facing changes?

Yes, no panics and the ability to directly create FSB arrays with zero-length items.

Copy link
Contributor

@Jefffrey Jefffrey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems reasonable to me

let zero_sized_with_non_empty_buffer = FixedSizeBinaryArray::try_new(0, buffer, None);
assert!(
matches!(
zero_sized_with_non_empty_buffer,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps assert the contents of the string as is done above (err.to_string())

@Jefffrey Jefffrey merged commit d76bfb1 into apache:main Nov 29, 2025
26 checks passed
@Jefffrey
Copy link
Contributor

Thanks @tobixdev

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

arrow Changes to the arrow crate

Projects

None yet

Development

Successfully merging this pull request may close these issues.

FixedSizeBinaryArray::try_new(...) Panics with Item Length of Zero

2 participants