alamb commented on code in PR #18087:
URL: https://github.com/apache/datafusion/pull/18087#discussion_r2436968088


##########
datafusion/spark/src/function/string/concat.rs:
##########
@@ -31,6 +32,10 @@ use std::sync::Arc;
 ///
 /// Concatenates multiple input strings into a single string.
 /// Returns NULL if any input is NULL.
+///
+/// Differences with DataFusion concat:

Review Comment:
   ❤️ 



##########
datafusion/spark/src/function/string/concat.rs:
##########
@@ -166,99 +178,50 @@ fn compute_null_mask(
             .collect();
         let arrays = arrays?;
 
-        // Compute NULL mask
-        let mut null_mask = vec![false; array_len];
-        for array in &arrays {
-            for (i, null_flag) in 
null_mask.iter_mut().enumerate().take(array_len) {
-                if array.is_null(i) {
-                    *null_flag = true;
-                }
-            }
-        }
+        // Use NullBuffer::union to combine all null buffers
+        let combined_nulls = arrays
+            .iter()
+            .map(|arr| arr.nulls())
+            .fold(None, |acc, nulls| NullBuffer::union(acc.as_ref(), nulls));
 
-        Ok(Some(null_mask))
+        match combined_nulls {
+            Some(nulls) => Ok(NullMaskResolution::Apply(nulls)),
+            None => Ok(NullMaskResolution::NoMask),
+        }
     }
 }
 
-/// Apply NULL mask to the result
+/// Apply NULL mask to the result using NullBuffer::union
 fn apply_null_mask(
     result: ColumnarValue,
-    null_mask: Option<Vec<bool>>,
+    null_mask: NullMaskResolution,
 ) -> Result<ColumnarValue> {
     match (result, null_mask) {
-        // Scalar with NULL mask means return NULL
-        (ColumnarValue::Scalar(_), None) => {
+        // Scalar with ReturnNull mask means return NULL

Review Comment:
   👨‍🍳 👌 



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