`substring` errors when the bytes under a null `Utf8` slot would be cut inside a character
Maintainers usually reply within 1 day
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 72/100
Research direction
Start in arrow-string/src/substring.rs, in byte_substring, where check_char_boundary runs on every slot. string_view_substring already skips null slots before the same check, so it is the reference for the change. Reproduce with the nullif example in the issue, where the first slot is null and cuts inside a multi-byte character. Done when that case returns null for the slot instead of an error, non-null invalid boundaries still error, and the substring tests pass.
Written by the indexing model from the issue text.
Description
Describe the bug
substring on a StringArray or LargeStringArray checks char boundaries in every slot, including null slots. If a null slot covers a multi-byte character and the cut falls inside it, the whole call returns an error, although the output for that slot is null.
To Reproduce
use arrow_array::{BooleanArray, StringArray};
use arrow_select::nullif::nullif;
use arrow_string::substring::substring;
fn main() {
let array = nullif(&StringArray::from(vec!["\u{e9}", "ab"]), &BooleanArray::from(vec![true, false])).unwrap();
println!("{:?}", substring(&array, 1, None));
// Err(ComputeError("The offset 1 is at an invalid utf-8 boundary."))
}
Expected behavior
Ok with [null, "b"]. Only non-null values should be able to cause the documented char boundary error.
Additional context
The Columnar format lets a null slot cover a non-empty range with undefined contents. byte_substring computes the new start and end of every slot through check_char_boundary, with no null check (substring.rs). string_view_substring skips null slots before the same check (substring.rs), so a StringViewArray with a null view over the same bytes returns [null, "b"].
nullif keeps the bytes of the slots it sets to null, so its output has this shape. Arrays from other producers through FFI or IPC can too.
Found with property-based tests that build arrays in every physical layout the Arrow format allows.
- Dominant language
- Rust
- Stars
- 3.7k
- Forks
- 1.4k
- Avg merge
- 2d 8h
- Merged PRs (30d)
- 309
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from apache/arrow-rs
-
parquet: panic (index out of bounds) reading FIXED_LEN_BYTE_ARRAY dictionary page with out-of-range indexPossibly taken A pull request linked to this issue is open or already merged. Open
Difficulty 2/5 1-3 hours Newbie friendliness 83/100
Maintainers usually reply within 1 day
-
enhancement parquet
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 1 day
-
i256::to_f32 double-rounds through f64May be free again A pull request for this issue was closed without being merged. Open
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
apache/arrow-rs#11316 · 1 comment ·
Maintainers usually reply within 1 day
-
`null_if_overflow_precision` resets decimal precision and scale, changing valid valuesMay be free again A pull request for this issue was closed without being merged. Open
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
Maintainers usually reply within 1 day
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
apache/arrow-rs#9657 · 4 comments ·
Maintainers usually reply within 1 day
Similar issues
-
auto:producer auto:security
Difficulty 2/5 1-3 hours Newbie friendliness 66/100
fritzprix/libr-agent#2595 ·
Maintainers usually reply within 1 day
-
area:fs type:fix
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
Tripstack-Corp/spyc#1002 ·
Maintainers usually reply within 1 day
-
github_actions security
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
dekobon/big-code-analysis#1815 ·
Maintainers usually reply within 1 day
-
[Detail Bug] Request logs can be forged via control characters in fetch object keys (log injection)Open
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
s2-streamstore/cachey#211 ·
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day