Jefffrey commented on code in PR #21842:
URL: https://github.com/apache/datafusion/pull/21842#discussion_r3142229664


##########
datafusion/core/tests/sql/select.rs:
##########
@@ -174,6 +174,38 @@ async fn prepared_statement_type_coercion() -> Result<()> {
     Ok(())
 }
 
+#[tokio::test]
+async fn make_array_null_typed_column_preserves_rows() -> Result<()> {

Review Comment:
   Let's remove this test as the SLT one is sufficient



##########
datafusion/functions-nested/src/make_array.rs:
##########
@@ -256,3 +258,31 @@ pub fn coerce_types_inner(arg_types: &[DataType], name: 
&str) -> Result<Vec<Data
         )
     }
 }
+
+#[cfg(test)]
+mod tests {
+    use super::*;
+    use arrow::array::ListArray;
+
+    #[test]
+    fn make_array_inner_all_null_arrays_preserves_row_count_and_width() {

Review Comment:
   Same for these unit tests



##########
datafusion/functions-nested/src/make_array.rs:
##########
@@ -130,20 +129,23 @@ impl ScalarUDFImpl for MakeArray {
 /// Constructs an array using the input `data` as `ArrayRef`.
 /// Returns a reference-counted `Array` instance result.
 pub(crate) fn make_array_inner(arrays: &[ArrayRef]) -> Result<ArrayRef> {
-    let data_type = arrays.iter().find_map(|arg| {
-        let arg_type = arg.data_type();
-        (!arg_type.is_null()).then_some(arg_type)
-    });
-
-    let data_type = data_type.unwrap_or(&Null);
-    if data_type.is_null() {
-        // Either an empty array or all nulls:
-        let length = arrays.iter().map(|a| a.len()).sum();
-        let array = new_null_array(&Null, length);
+    // Zero arguments are the only case that should build a scalar empty list.
+    if arrays.is_empty() {
+        let array = new_null_array(&DataType::Null, 0);
         Ok(Arc::new(
             SingleRowListArrayBuilder::new(array).build_list_array(),
         ))
     } else {
+        // All-null inputs still need to flow through `array_array()` so rows
+        // are built per input row instead of collapsing to one value.
+        let data_type = arrays

Review Comment:
   I feel we can get this from the return type, which is provided in the 
[`ScalarFunctionArgs`](https://docs.rs/datafusion/latest/datafusion/logical_expr/struct.ScalarFunctionArgs.html)
 in `invoke_with_args`, so we some plumbing we can reuse that instead of having 
this logic



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