sunchao commented on code in PR #5416:
URL: https://github.com/apache/datafusion-comet/pull/5416#discussion_r3836722894


##########
native/spark-expr/src/string_funcs/split.rs:
##########
@@ -160,9 +213,37 @@ pub fn spark_split_sql(args: &[ColumnarValue]) -> 
DataFusionResult<ColumnarValue
                 _ => return exec_err!("split_sql delimiter must be a string"),
             };
 
-            let result = split_sql_string(string.as_ref().unwrap(), delimiter);
-            let string_array = GenericStringArray::<i32>::from(result);
-            let list_array = create_list_array(Arc::new(string_array));
+            let string = string.clone().unwrap();
+            let mut str_offsets = BufferBuilder::<i32>::new(8);
+            let mut str_values = BufferBuilder::<u8>::new(string.len());
+            str_offsets.append(0);
+
+            if delimiter.is_empty() {
+                for ch in string.chars() {

Review Comment:
   [P2] Preserve the whole string for an empty SQL delimiter
   
   `StringSplitSQL` treats an empty delimiter as "do not split", but this 
scalar branch now emits one item per character. For a Parquet table `t(s)` 
containing `'abc'`, `SELECT split_part((SELECT max(s) FROM t), '', 1) FROM t` 
retains the scalar subquery through normal Spark optimization, and Comet's 4.x 
route passes its string result to `split_sql` as a scalar. Exact-base/head 
native UDF + `ListExtract` probes return `'abc'` versus `'a'` (part `2` changes 
from `''` to `'b'`), while Spark 4.0.2 and the unchanged array paths preserve 
the whole input. This is the default literal SQL-split route, not the 
incompatible-regex opt-in. Please append the whole string once for an empty 
delimiter and retain a scalar/array regression test.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to