@@ -38,8 +38,8 @@ impl AggregateFnVTable for AllNan {
3838 Ok ( None )
3939 }
4040
41- fn return_dtype ( & self , _options : & Self :: Options , _input_dtype : & DType ) -> Option < DType > {
42- Some ( DType :: Bool ( Nullability :: NonNullable ) )
41+ fn return_dtype ( & self , _options : & Self :: Options , input_dtype : & DType ) -> Option < DType > {
42+ has_nans ( input_dtype ) . then_some ( DType :: Bool ( Nullability :: Nullable ) )
4343 }
4444
4545 fn partial_dtype ( & self , options : & Self :: Options , input_dtype : & DType ) -> Option < DType > {
@@ -49,9 +49,9 @@ impl AggregateFnVTable for AllNan {
4949 fn empty_partial (
5050 & self ,
5151 _options : & Self :: Options ,
52- input_dtype : & DType ,
52+ _input_dtype : & DType ,
5353 ) -> VortexResult < Self :: Partial > {
54- Ok ( has_nans ( input_dtype ) )
54+ Ok ( true )
5555 }
5656
5757 fn combine_partials ( & self , partial : & mut Self :: Partial , other : Scalar ) -> VortexResult < ( ) > {
@@ -60,7 +60,7 @@ impl AggregateFnVTable for AllNan {
6060 }
6161
6262 fn to_scalar ( & self , partial : & Self :: Partial ) -> VortexResult < Scalar > {
63- Ok ( Scalar :: bool ( * partial, Nullability :: NonNullable ) )
63+ Ok ( Scalar :: bool ( * partial, Nullability :: Nullable ) )
6464 }
6565
6666 fn reset ( & self , partial : & mut Self :: Partial ) {
@@ -161,24 +161,31 @@ mod tests {
161161 }
162162
163163 #[ test]
164- fn all_nan_false_for_non_float_values ( ) -> VortexResult < ( ) > {
165- let mut ctx = LEGACY_SESSION . create_execution_ctx ( ) ;
164+ fn all_nan_unsupported_for_non_float_values ( ) -> VortexResult < ( ) > {
166165 let dtype = DType :: Primitive ( PType :: I32 , Nullability :: Nullable ) ;
166+ assert ! ( Accumulator :: try_new( AllNan , EmptyOptions , dtype) . is_err( ) ) ;
167+ Ok ( ( ) )
168+ }
169+
170+ #[ test]
171+ fn all_nan_false_with_null ( ) -> VortexResult < ( ) > {
172+ let mut ctx = LEGACY_SESSION . create_execution_ctx ( ) ;
173+ let dtype = DType :: Primitive ( PType :: F32 , Nullability :: Nullable ) ;
167174 let mut acc = Accumulator :: try_new ( AllNan , EmptyOptions , dtype) ?;
168175
169- let batch = PrimitiveArray :: from_option_iter ( [ Some ( 1i32 ) , None ] ) . into_array ( ) ;
176+ let batch = PrimitiveArray :: from_option_iter ( [ Some ( f32 :: NAN ) , None ] ) . into_array ( ) ;
170177 acc. accumulate ( & batch, & mut ctx) ?;
171178
172179 assert ! ( !bool :: try_from( & acc. finish( ) ?) ?) ;
173180 Ok ( ( ) )
174181 }
175182
176183 #[ test]
177- fn all_nan_false_for_empty_non_float_values ( ) -> VortexResult < ( ) > {
178- let dtype = DType :: Primitive ( PType :: I32 , Nullability :: Nullable ) ;
184+ fn all_nan_true_for_empty_float_values ( ) -> VortexResult < ( ) > {
185+ let dtype = DType :: Primitive ( PType :: F32 , Nullability :: Nullable ) ;
179186 let mut acc = Accumulator :: try_new ( AllNan , EmptyOptions , dtype) ?;
180187
181- assert ! ( ! bool :: try_from( & acc. finish( ) ?) ?) ;
188+ assert ! ( bool :: try_from( & acc. finish( ) ?) ?) ;
182189 Ok ( ( ) )
183190 }
184191}
0 commit comments