Skip to content

Commit 1196126

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 1196126

1 file changed

Lines changed: 10 additions & 6 deletions

File tree

datafusion/functions/src/unicode/character_length.rs

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -140,14 +140,18 @@ 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_empty() {
149+
T::default_value()
150+
} else if value.is_ascii() {
151+
T::Native::usize_as(value.len())
152+
} else {
153+
T::Native::usize_as(value.chars().count())
154+
}
151155
}
152156
})
153157
.collect();

0 commit comments

Comments
 (0)