File tree Expand file tree Collapse file tree 1 file changed +4
-3
lines changed
datafusion/spark/src/function/string Expand file tree Collapse file tree 1 file changed +4
-3
lines changed Original file line number Diff line number Diff line change @@ -108,12 +108,12 @@ impl ScalarUDFImpl for SparkSubstring {
108108
109109 fn return_type ( & self , _arg_types : & [ DataType ] ) -> Result < DataType > {
110110 datafusion_common:: internal_err!(
111- "return_type should not be called for Spark substr "
111+ "return_type should not be called for Spark substring "
112112 )
113113 }
114114
115115 fn return_field_from_args ( & self , args : ReturnFieldArgs < ' _ > ) -> Result < FieldRef > {
116- // Spark semantics: substr returns NULL if ANY input is NULL
116+ // Spark semantics: substring returns NULL if ANY input is NULL
117117 let nullable = args. arg_fields . iter ( ) . any ( |f| f. is_nullable ( ) ) ;
118118
119119 Ok ( Arc :: new ( Field :: new (
@@ -165,7 +165,8 @@ fn spark_start_to_datafusion_start(start: i64, len: usize) -> i64 {
165165 if start >= 0 {
166166 start. max ( 1 )
167167 } else {
168- let start = start + len as i64 + 1 ;
168+ let len_i64 = i64:: try_from ( len) . unwrap_or ( i64:: MAX ) ;
169+ let start = start. saturating_add ( len_i64) . saturating_add ( 1 ) ;
169170 start. max ( 1 )
170171 }
171172}
You can’t perform that action at this time.
0 commit comments