jayzhan211 commented on code in PR #7338:
URL: https://github.com/apache/arrow-datafusion/pull/7338#discussion_r1303120889
##########
datafusion/sql/src/expr/value.rs:
##########
@@ -151,16 +151,51 @@ impl<'a, S: ContextProvider> SqlToRel<'a, S> {
let data_types: HashSet<DataType> =
values.iter().map(|e| e.get_datatype()).collect();
- if data_types.is_empty() {
- Ok(lit(ScalarValue::new_list(None, DataType::Utf8)))
- } else if data_types.len() > 1 {
- Err(DataFusionError::NotImplemented(format!(
- "Arrays with different types are not supported:
{data_types:?}",
- )))
- } else {
- let data_type = values[0].get_datatype();
+ match data_types.len() {
+ 0 => Ok(lit(ScalarValue::new_list(None, DataType::Utf8))),
+ 1 => {
+ let data_type = values[0].get_datatype();
+
+ Ok(lit(ScalarValue::new_list(Some(values), data_type)))
+ }
+ // Check whether one of them is null
+ 2 => {
+ let has_null_type = data_types.contains(&DataType::Null);
+ if has_null_type {
+ // convert to Vec for indexing
+ let data_types =
data_types.into_iter().collect::<Vec<_>>();
+ let non_null_type = if data_types[0] == DataType::Null {
Review Comment:
I assume there is only null and `one` non-null, if not, this fails
--
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]