jayzhan211 commented on code in PR #7338:
URL: https://github.com/apache/arrow-datafusion/pull/7338#discussion_r1303136228


##########
datafusion/optimizer/src/analyzer/type_coercion.rs:
##########
@@ -543,6 +543,77 @@ fn coerce_arguments_for_signature(
         .collect::<Result<Vec<_>>>()
 }
 
+// TODO: Add this function to arrow-rs
+fn get_list_base_type(data_type: &DataType) -> Result<DataType> {
+    match data_type {
+        DataType::List(field) => match field.data_type() {
+            DataType::List(_) => get_list_base_type(field.data_type()),
+            base_type => Ok(base_type.clone()),
+        },
+
+        _ => Ok(data_type.clone()),
+    }
+}
+
+fn get_list_from_base_type(
+    data_type: &DataType,
+    base_type: &DataType,
+) -> Result<DataType> {
+    match data_type {
+        DataType::List(field) => match field.data_type() {
+            DataType::List(inner_field) => 
Ok(DataType::List(Arc::new(Field::new(
+                field.name(),
+                get_list_from_base_type(inner_field.data_type(), base_type)?,
+                field.is_nullable(),
+            )))),
+            _ => Ok(DataType::List(Arc::new(Field::new(
+                field.name(),
+                base_type.clone(),
+                field.is_nullable(),
+            )))),
+        },
+
+        _ => Ok(base_type.clone()),
+    }
+}
+
+fn coerce_nulls_for_array_append(

Review Comment:
   Actually, I just try to deal with append and prepend. I have not thought 
deeply about other array functions yet, so not sure if they have similar 
coercion, If yes, having one function for them is pretty nice.



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