edmondop commented on code in PR #7897:
URL: https://github.com/apache/arrow-datafusion/pull/7897#discussion_r1373952693


##########
datafusion/physical-expr/src/array_expressions.rs:
##########
@@ -1478,6 +1480,53 @@ macro_rules! to_string {
     }};
 }
 
+
+/// Array_union SQL function
+pub fn array_union(args: &[ArrayRef]) -> Result<ArrayRef> {
+    if args.len() != 2 {
+        return exec_err!("array_union needs two arguments")
+    }
+    let array1 = &args[0];
+    let array2= &args[1];
+
+    check_datatypes("array_union", &[array1, array2])?;
+    let list1 = as_list_array(array1)?;
+    let list2 = as_list_array(array2)?;
+    eprintln!("{:?}",list1.value_type());
+    match (list1.value_type(), list2.value_type()){
+        (DataType::Null, _) => {
+            Ok(array2.clone())
+        },
+        (_, DataType::Null) => {
+            Ok(array1.clone())
+        }
+        (DataType::List(_), DataType::List(_)) => {
+            let result = concat_internal(args)?;
+            let row_converter = RowConverter::new(vec![
+                SortField::new(
+                    args[0].data_type().clone()
+                )
+            ]
+            )?;
+            let converted = row_converter.convert_columns(&[result])?;

Review Comment:
   I am doubting also that my pattern matching is wrong, since the following 
block produces the following output:
   
   ```rust
          (_data_type1, _data_type_2) => {
               eprintln!("Array1 {:?}",array1);
               eprintln!("Array2 {:?}",array2);
               let arrays = vec![array1.as_ref(), array2.as_ref()];
               let result = arrow::compute::concat(arrays.as_slice())?;
               eprintln!("Result {:?}",result);
               deduplicate_array(result)
           }
   ```
   
   The row seems to be concatenated "vertically" rather than horizontally
   
   ```rust
   Array1 ListArray
   [
     PrimitiveArray<Int64>
   [
     1,
     2,
     3,
     4,
   ],
   ]
   Array2 ListArray
   [
     PrimitiveArray<Int64>
   [
     5,
     6,
     3,
     4,
   ],
   ]
   Result ListArray
   [
     PrimitiveArray<Int64>
   [
     1,
     2,
     3,
     4,
   ],
     PrimitiveArray<Int64>
   [
     5,
     6,
     3,
     4,
   ],
   ]
   ```



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

Reply via email to