Weijun-H commented on code in PR #8333:
URL: https://github.com/apache/arrow-datafusion/pull/8333#discussion_r1406257923


##########
datafusion/physical-expr/src/array_expressions.rs:
##########
@@ -227,16 +227,29 @@ fn compute_array_dims(arr: Option<ArrayRef>) -> 
Result<Option<Vec<Option<u64>>>>
 }
 
 fn check_datatypes(name: &str, args: &[&ArrayRef]) -> Result<()> {
-    let data_type = args[0].data_type();
-    if !args.iter().all(|arg| {
-        arg.data_type().equals_datatype(data_type)
-            || arg.data_type().equals_datatype(&DataType::Null)
-    }) {
-        let types = args.iter().map(|arg| arg.data_type()).collect::<Vec<_>>();
-        return plan_err!("{name} received incompatible types: '{types:?}'.");
+    let mut data_types = args
+        .iter()
+        .map(|arg| arg.data_type())
+        .collect::<HashSet<_>>();
+    match data_types.len() {
+        1 => Ok(()),
+        2 => {
+            if data_types.remove(&DataType::Null) {
+                Ok(())
+            } else {
+                Err(DataFusionError::Plan(format!(
+                    "{name} received incompatible types: '{types:?}'.",
+                    name = name,
+                    types = args.iter().map(|arg| 
arg.data_type()).collect::<Vec<_>>()
+                )))

Review Comment:
   ```suggestion
                   let types = args.iter().map(|arg| 
arg.data_type()).collect::<Vec<_>>();
                   plan_err!("{name} received incompatible types: '{types:?}'.")
   ```



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