goldmedal commented on code in PR #12490:
URL: https://github.com/apache/datafusion/pull/12490#discussion_r1768980396
##########
datafusion/expr-common/src/type_coercion/binary.rs:
##########
@@ -1021,6 +1021,22 @@ fn list_coercion(lhs_type: &DataType, rhs_type:
&DataType) -> Option<DataType> {
use arrow::datatypes::DataType::*;
match (lhs_type, rhs_type) {
(List(_), List(_)) => Some(lhs_type.clone()),
+ (LargeList(_), List(_)) => Some(lhs_type.clone()),
+ (List(_), LargeList(_)) => Some(rhs_type.clone()),
+ (LargeList(_), LargeList(_)) => Some(lhs_type.clone()),
+ (List(_), FixedSizeList(_, _)) => Some(lhs_type.clone()),
+ (FixedSizeList(_, _), List(_)) => Some(rhs_type.clone()),
+ // Coerce to the left side FixedSizeList type if the list lengths are
the same,
+ // otherwise coerce to list with the left type for dynamic length
+ (FixedSizeList(lf, ls), FixedSizeList(_, rs)) => {
+ if ls == rs {
+ Some(lhs_type.clone())
+ } else {
+ Some(List(Arc::clone(lf)))
+ }
+ }
Review Comment:
Because we can't cast a FixedSizeList to a different length FixedSizeList,
```
> select arrow_cast(arrow_cast([1,2], 'FixedSizeList(2, Int64)'),
'FixedSizeList(3, Int64)');
This feature is not implemented: Unsupported CAST from FixedSizeList(Field {
name: "item", data_type: Int64, nullable: true, dict_id: 0, dict_is_ordered:
false, metadata: {} }, 2) to FixedSizeList(Field { name: "item", data_type:
Int64, nullable: true, dict_id: 0, dict_is_ordered: false, metadata: {} }, 3)
```
I choose to use the `List` for the dynamic length.
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]