hsdfat opened a new pull request, #12006:
URL: https://github.com/apache/arrow-rs/pull/12006
# Which issue does this PR close?
- Follow-up to #10995, which made the other `substring` arms saturate large
lengths. The `Utf8View` / `BinaryView` arms added in #10672 were missed.
# Rationale for this change
`view_substring_range` computed the end as `new_start.saturating_add(length
as i64)`. For `length > i64::MAX` the cast wraps negative, so the end lands
before the start:
- `substring(&BinaryViewArray["hello"], 1, Some(u64::MAX))` panics with
`slice index starts at 1 but ends at 0`;
- the same call on `StringViewArray` returns `ComputeError("The offset
9223372036854775808 is at an invalid utf-8 boundary.")`.
`LargeUtf8` and `LargeBinary` return `"ello"` for the same input.
# What changes are included in this PR?
Use the existing `u64_to_i64_saturating(length)` in `view_substring_range`,
like the other arms.
# Are these changes tested?
Yes. A new test checks that `Utf8View` matches `LargeUtf8` and `BinaryView`
matches `LargeBinary` for several starts (including negative and beyond the
end) with lengths `2^63` and `u64::MAX`.
# Are there any significant user-facing changes?
No.
---
AI disclosure: the bug was found and the patch and test drafted with AI
assistance (Claude); I reviewed every line, verified the failing test
before/after the fix, and ran fmt/clippy/tests for the crate.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]