We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
datafusion-spark
1 parent c36d895 commit 437d5e0Copy full SHA for 437d5e0
1 file changed
datafusion/spark/src/function/string/substring.rs
@@ -159,7 +159,10 @@ fn spark_substring(args: &[ArrayRef]) -> Result<ArrayRef> {
159
/// - Zero start: treated as 1
160
/// - Negative start: counts from end of string
161
///
162
-/// Returns the converted 1-based start position for use with `get_true_start_end`.
+/// 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.
166
#[inline]
167
fn spark_start_to_datafusion_start(start: i64, len: usize) -> i64 {
168
if start >= 0 {
0 commit comments