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


##########
datafusion/common/src/utils/array_utils.rs:
##########
@@ -0,0 +1,171 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+//! Array concatenation utilities
+
+use std::sync::Arc;
+
+use crate::cast::as_generic_list_array;
+use crate::error::_exec_datafusion_err;
+use crate::utils::list_ndims;
+use crate::Result;
+use arrow::array::{
+    Array, ArrayData, ArrayRef, GenericListArray, NullBufferBuilder, 
OffsetSizeTrait,
+};
+use arrow::buffer::OffsetBuffer;
+use arrow::datatypes::{DataType, Field};
+
+/// Concatenates arrays
+pub fn concat_arrays(args: &[ArrayRef]) -> Result<ArrayRef> {
+    if args.is_empty() {
+        return Err(_exec_datafusion_err!(
+            "concat_arrays expects at least one argument"
+        ));
+    }
+
+    let mut all_null = true;
+    let mut large_list = false;
+    for arg in args {
+        match arg.data_type() {
+            DataType::Null => continue,
+            DataType::LargeList(_) => large_list = true,
+            _ => (),
+        }
+        if arg.null_count() < arg.len() {
+            all_null = false;
+        }
+    }
+
+    if all_null {
+        // Return a null array with the same type as the first non-null-type 
argument
+        let return_type = args
+            .iter()
+            .map(|arg| arg.data_type())
+            .find(|d| !d.is_null())
+            .unwrap_or_else(|| args[0].data_type());

Review Comment:
   I've restored it to use find_or_first as it was originally. Also added back 
the original comment "// Safe because args is non-empty".



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