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


##########
native/spark-expr/src/string_funcs/split.rs:
##########
@@ -172,22 +253,214 @@ pub fn spark_split_sql(args: &[ColumnarValue]) -> 
DataFusionResult<ColumnarValue
     }
 }
 
-fn split_array(
-    string_array: &dyn arrow::array::Array,
+fn is_regex_literal(pattern: &str) -> bool {
+    !pattern.chars().any(|c| {
+        matches!(
+            c,
+            '.' | '^' | '$' | '*' | '+' | '?' | '(' | ')' | '[' | ']' | '{' | 
'}' | '|' | '\\'
+        )
+    })
+}
+
+#[inline]
+fn push_split_literal<'a, O: OffsetSizeTrait>(
+    string: &'a str,
+    delimiter: &str,
+    limit: i32,
+    offsets: &mut BufferBuilder<O>,
+    values: &mut BufferBuilder<u8>,
+    scratch: &mut Vec<&'a str>,
+) {
+    if limit == 0 {
+        scratch.clear();
+        scratch.extend(string.split(delimiter));
+        while scratch.last().is_some_and(|s| s.is_empty()) {
+            scratch.pop();
+        }
+        if scratch.is_empty() {
+            append_str("", offsets, values);
+        } else {
+            for &p in scratch.iter() {
+                append_str(p, offsets, values);
+            }
+        }
+    } else if limit > 0 {
+        let cap = (limit - 1) as usize;
+        let mut count = 0;
+        let mut last_end = 0;
+        for (start, _) in string.match_indices(delimiter) {

Review Comment:
   [P2] Make both literal split loops pass the Clippy gate
   
   This manual counter and the equivalent loop in `push_split_char` (line 333) 
trigger `clippy::explicit_counter_loop`. Fresh Clippy runs on the exact 
base/head module, with the crate's lint attributes and `-D warnings`, pass at 
the base but fail at the head on these two loops. 
`.github/actions/rust-test/action.yaml` runs `cargo clippy --color=never 
--all-targets --workspace -- -D warnings`, so these loops will fail the 
Rust-test check once the currently blocked workflows run. Please use 
`.enumerate()` in both helpers.



-- 
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