Skip to content

fix(arrow-cast): return an error instead of panicking on view-to-byte offset overflow - #12560

Open
adriangb wants to merge 1 commit into
apache:mainfrom
adriangb:fix-view-to-byte-offset-overflow
Open

adriangb wants to merge 1 commit into
apache:mainfrom
adriangb:fix-view-to-byte-offset-overflow

Conversation

@adriangb

@adriangb adriangb commented Dec 4, 2026

Copy link
Copy Markdown
Contributor

Which issue does this PR close?

Rationale for this change

cast_view_to_byte returns a Result and already computes the total value length. But it does not check that length against the offset limit of the target type. So a Utf8View or BinaryView array with more than i32::MAX value bytes panics in GenericByteBuilder::append_value when it is cast to Utf8 or Binary.

What changes are included in this PR?

cast_view_to_byte returns ArrowError::ComputeError when the total value length exceeds TO::Offset::MAX_OFFSET. The message matches the list casts in arrow-cast/src/cast/list.rs.

Are these changes tested?

Yes. A new unit test builds Utf8View and BinaryView arrays whose views share one 1 MiB buffer, so the logical length passes i32::MAX without a 2 GiB allocation.

Are there any user-facing changes?

The cast returns an error where it panicked before.

@adriangb

adriangb commented Dec 4, 2026

Copy link
Copy Markdown
Contributor Author

@neilconway @Jefffrey would either of you be interested in working on this change with me?

@adriangb
adriangb marked this pull request as ready for review December 4, 2026 21:12

This branch has not been deployed

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

Labels

arrow-kernels Crates that transform arrow data (e.g. compute, cast)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Casting a large Utf8View/BinaryView array to Utf8/Binary panics with "byte array offset overflow"

1 participant