@@ -23,19 +23,19 @@ use std::sync::Arc;
2323
2424use crate :: operator:: Operator ;
2525
26- use arrow:: array:: { Array , new_empty_array } ;
26+ use arrow:: array:: { new_empty_array , Array } ;
2727use arrow:: compute:: can_cast_types;
2828use arrow:: datatypes:: IntervalUnit :: MonthDayNano ;
2929use arrow:: datatypes:: TimeUnit :: * ;
3030use arrow:: datatypes:: {
31- DECIMAL32_MAX_PRECISION , DECIMAL32_MAX_SCALE , DECIMAL64_MAX_PRECISION ,
32- DECIMAL64_MAX_SCALE , DECIMAL128_MAX_PRECISION , DECIMAL128_MAX_SCALE ,
33- DECIMAL256_MAX_PRECISION , DECIMAL256_MAX_SCALE , DataType , Field , FieldRef , Fields ,
34- TimeUnit ,
31+ DataType , Field , FieldRef ,
32+ Fields , TimeUnit , DECIMAL128_MAX_PRECISION ,
33+ DECIMAL128_MAX_SCALE , DECIMAL256_MAX_PRECISION , DECIMAL256_MAX_SCALE , DECIMAL32_MAX_PRECISION , DECIMAL32_MAX_SCALE , DECIMAL64_MAX_PRECISION ,
34+ DECIMAL64_MAX_SCALE ,
3535} ;
3636use datafusion_common:: {
37- Diagnostic , Result , Span , Spans , exec_err , internal_err , not_impl_err ,
38- plan_datafusion_err , plan_err ,
37+ exec_err , internal_err , not_impl_err , plan_datafusion_err , plan_err , Diagnostic , Result ,
38+ Span , Spans ,
3939} ;
4040use itertools:: Itertools ;
4141
@@ -528,11 +528,12 @@ enum TypeCategory {
528528impl From < & DataType > for TypeCategory {
529529 fn from ( data_type : & DataType ) -> Self {
530530 match data_type {
531- // Dict is a special type in arrow, we check the value type
531+ // Dict and REE are special types in arrow, we check the value type.
532532 DataType :: Dictionary ( _, v) => {
533533 let v = v. as_ref ( ) ;
534534 TypeCategory :: from ( v)
535535 }
536+ DataType :: RunEndEncoded ( _, v) => TypeCategory :: from ( v. data_type ( ) ) ,
536537 _ => {
537538 if data_type. is_numeric ( ) {
538539 return TypeCategory :: Numeric ;
@@ -709,6 +710,27 @@ fn type_union_resolution_coercion(
709710 None => None ,
710711 }
711712 }
713+ (
714+ DataType :: RunEndEncoded ( lhs_run, lhs_val) ,
715+ DataType :: RunEndEncoded ( rhs_run, rhs_val) ,
716+ ) => {
717+ let new_run =
718+ type_union_resolution_coercion ( lhs_run. data_type ( ) , rhs_run. data_type ( ) ) ?;
719+ let new_val =
720+ type_union_resolution_coercion ( lhs_val. data_type ( ) , rhs_val. data_type ( ) ) ?;
721+ Some ( DataType :: RunEndEncoded (
722+ Arc :: new ( lhs_run. as_ref ( ) . clone ( ) . with_data_type ( new_run) ) ,
723+ Arc :: new ( lhs_val. as_ref ( ) . clone ( ) . with_data_type ( new_val) ) ,
724+ ) )
725+ }
726+ ( DataType :: RunEndEncoded ( run, val) , other)
727+ | ( other, DataType :: RunEndEncoded ( run, val) ) => {
728+ let new_val = type_union_resolution_coercion ( val. data_type ( ) , other) ?;
729+ Some ( DataType :: RunEndEncoded (
730+ Arc :: clone ( run) ,
731+ Arc :: new ( val. as_ref ( ) . clone ( ) . with_data_type ( new_val) ) ,
732+ ) )
733+ }
712734 ( DataType :: Struct ( lhs) , DataType :: Struct ( rhs) ) => {
713735 if lhs. len ( ) != rhs. len ( ) {
714736 return None ;
0 commit comments