EeshanBembi commented on code in PR #18137:
URL: https://github.com/apache/datafusion/pull/18137#discussion_r2658921205


##########
datafusion/functions/src/string/concat.rs:
##########
@@ -65,13 +71,64 @@ impl Default for ConcatFunc {
 
 impl ConcatFunc {
     pub fn new() -> Self {
-        use DataType::*;
         Self {
-            signature: Signature::variadic(
-                vec![Utf8View, Utf8, LargeUtf8],
-                Volatility::Immutable,
-            ),
+            signature: Signature::user_defined(Volatility::Immutable),
+        }
+    }
+
+    /// Get the string type with highest precedence: Utf8View > LargeUtf8 > 
Utf8
+    fn get_string_type_precedence(&self, arg_types: &[DataType]) -> DataType {
+        use DataType::*;
+
+        for data_type in arg_types {
+            if data_type == &Utf8View {
+                return Utf8View;
+            }
+        }
+
+        for data_type in arg_types {
+            if data_type == &LargeUtf8 {
+                return LargeUtf8;
+            }
+        }
+
+        Utf8
+    }
+
+    /// Concatenate array arguments
+    fn concat_arrays(&self, args: &[ColumnarValue]) -> Result<ColumnarValue> {
+        if args.is_empty() {
+            return plan_err!("concat requires at least one argument");
         }
+
+        // Convert ColumnarValue arguments to ArrayRef
+        let arrays: Result<Vec<Arc<dyn Array>>> = args
+            .iter()
+            .map(|arg| match arg {
+                ColumnarValue::Array(arr) => Ok(Arc::clone(arr)),
+                ColumnarValue::Scalar(scalar) => scalar.to_array_of_size(1),
+            })
+            .collect();
+        let arrays = arrays?;
+
+        // Check if all arrays are null - concat errors in this case

Review Comment:
   Yes, this matches PostgreSQL's behavior. I've added a comment to clarify:
    ` // This matches PostgreSQL behavior where concat() with all NULL values 
returns an error`



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