Skip to content

Commit 7beb6f7

Browse files
Dandandanclaude
andcommitted
Restore null check in non-ASCII offset path
Restores the is_null(i) early-exit for the non-ASCII StringArray path to avoid value_unchecked on null entries, fixing a regression on short UTF-8 StringArray inputs. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 71278bf commit 7beb6f7

1 file changed

Lines changed: 8 additions & 6 deletions

File tree

datafusion/functions/src/unicode/character_length.rs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -140,14 +140,16 @@ where
140140
} else {
141141
let values: Vec<T::Native> = (0..array.len())
142142
.map(|i| {
143-
// Safety: i is within bounds
144-
let value = unsafe { array.value_unchecked(i) };
145-
if value.is_empty() {
143+
if array.is_null(i) {
146144
T::default_value()
147-
} else if value.is_ascii() {
148-
T::Native::usize_as(value.len())
149145
} else {
150-
T::Native::usize_as(value.chars().count())
146+
// Safety: i is within bounds and not null
147+
let value = unsafe { array.value_unchecked(i) };
148+
if value.is_ascii() {
149+
T::Native::usize_as(value.len())
150+
} else {
151+
T::Native::usize_as(value.chars().count())
152+
}
151153
}
152154
})
153155
.collect();

0 commit comments

Comments
 (0)