Skip to content

Commit 437d5e0

Browse files
committed
chore: fix datafusion-spark substring
1 parent c36d895 commit 437d5e0

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

datafusion/spark/src/function/string/substring.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,10 @@ fn spark_substring(args: &[ArrayRef]) -> Result<ArrayRef> {
159159
/// - Zero start: treated as 1
160160
/// - Negative start: counts from end of string
161161
///
162-
/// Returns the converted 1-based start position for use with `get_true_start_end`.
162+
/// The result may be `<= 0` when a negative start lands before the string
163+
/// (e.g. `start=-10` on a 3-char string gives `-6`). Such values are passed
164+
/// through to `get_true_start_end`, which clamps them and yields an empty
165+
/// slice — matching Spark's behavior for out-of-range negative positions.
163166
#[inline]
164167
fn spark_start_to_datafusion_start(start: i64, len: usize) -> i64 {
165168
if start >= 0 {

0 commit comments

Comments
 (0)