comphead commented on code in PR #8333:
URL: https://github.com/apache/arrow-datafusion/pull/8333#discussion_r1409612805
##########
datafusion/physical-expr/src/array_expressions.rs:
##########
@@ -227,16 +227,25 @@ 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 data_types = args
+ .iter()
+ .map(|arg| arg.data_type())
+ .collect::<HashSet<_>>();
+ match data_types.len() {
+ 1 => Ok(()),
+ 2 => {
+ if data_types.contains(&DataType::Null) {
+ Ok(())
+ } else {
+ let types = args.iter().map(|arg|
arg.data_type()).collect::<Vec<_>>();
Review Comment:
Sorry, my bad, its it err message.
we may want to avoid code duplication for
```
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]