@@ -30,7 +30,8 @@ use arrow_buffer::NullBuffer;
3030
3131use arrow_schema:: FieldRef ;
3232use datafusion_common:: cast:: {
33- as_generic_string_array, as_int64_array, as_list_array, as_string_array,
33+ as_generic_list_array, as_generic_string_array, as_int64_array, as_list_array,
34+ as_null_array, as_string_array,
3435} ;
3536use datafusion_common:: utils:: array_into_list_array;
3637use datafusion_common:: {
@@ -939,12 +940,21 @@ pub fn array_concat(args: &[ArrayRef]) -> Result<ArrayRef> {
939940
940941/// Array_empty SQL function
941942pub fn array_empty ( args : & [ ArrayRef ] ) -> Result < ArrayRef > {
942- if args[ 0 ] . as_any ( ) . downcast_ref :: < NullArray > ( ) . is_some ( ) {
943+ if as_null_array ( & args[ 0 ] ) . is_ok ( ) {
943944 // Make sure to return Boolean type.
944945 return Ok ( Arc :: new ( BooleanArray :: new_null ( args[ 0 ] . len ( ) ) ) ) ;
945946 }
947+ let array_type = args[ 0 ] . data_type ( ) ;
946948
947- let array = as_list_array ( & args[ 0 ] ) ?;
949+ match array_type {
950+ DataType :: List ( _) => array_empty_dispatch :: < i32 > ( & args[ 0 ] ) ,
951+ DataType :: LargeList ( _) => array_empty_dispatch :: < i64 > ( & args[ 0 ] ) ,
952+ _ => internal_err ! ( "array_empty does not support type '{array_type:?}'." ) ,
953+ }
954+ }
955+
956+ fn array_empty_dispatch < O : OffsetSizeTrait > ( array : & ArrayRef ) -> Result < ArrayRef > {
957+ let array = as_generic_list_array :: < O > ( array) ?;
948958 let builder = array
949959 . iter ( )
950960 . map ( |arr| arr. map ( |arr| arr. len ( ) == arr. null_count ( ) ) )
0 commit comments