jayzhan211 commented on code in PR #8902:
URL: https://github.com/apache/arrow-datafusion/pull/8902#discussion_r1461779392
##########
datafusion/expr/src/type_coercion/functions.rs:
##########
@@ -104,23 +105,39 @@ fn get_valid_types(
let elem_base_type = datafusion_common::utils::base_type(elem_type);
let new_base_type = comparison_coercion(&array_base_type,
&elem_base_type);
- if new_base_type.is_none() {
- return internal_err!(
+ let new_base_type = new_base_type.ok_or_else(|| {
+ internal_datafusion_err!(
"Coercion from {array_base_type:?} to {elem_base_type:?} not
supported."
- );
- }
- let new_base_type = new_base_type.unwrap();
+ )
+ })?;
let array_type =
datafusion_common::utils::coerced_type_with_base_type_only(
array_type,
&new_base_type,
);
+ // type coercion for nested FixedSizeList
+ let elem_type =
datafusion_common::utils::coerced_type_with_base_type_only(
+ elem_type,
+ &elem_base_type,
+ );
+
+ let array_dim = datafusion_common::utils::list_ndims(&array_type);
+ let elem_dim = datafusion_common::utils::list_ndims(&elem_type);
+
match array_type {
- DataType::List(ref field) | DataType::LargeList(ref field) => {
- let elem_type = field.data_type();
+ DataType::List(ref field)
+ | DataType::LargeList(ref field)
+ | DataType::FixedSizeList(ref field, _) => {
+ // for the functions with signature 'array_element(array, int)'
+ let elem_type =
+ if elem_base_type.eq(&DataType::Null) && elem_dim !=
array_dim {
Review Comment:
I'm not sure why we need `elem_dim != array_dim` inside ArrayElement, since
their dimensions should never be the same.
--
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]