@@ -28,7 +28,6 @@ use vortex_array::aggregate_fn::fns::uncompressed_size_in_bytes::UncompressedSiz
2828use vortex_array:: aggregate_fn:: kernels:: DynAggregateKernel ;
2929use vortex_array:: aggregate_fn:: session:: AggregateFnSessionExt ;
3030use vortex_array:: array_session;
31- #[ cfg( target_pointer_width = "64" ) ]
3231use vortex_array:: arrays:: ConstantArray ;
3332use vortex_array:: arrays:: ListArray ;
3433use vortex_array:: arrays:: PrimitiveArray ;
@@ -272,13 +271,15 @@ fn sum_distinguishes_missing_input_from_zero(
272271 Ok ( ( ) )
273272}
274273
275- #[ test]
276- fn empty_chunk_preserves_counts ( ) -> VortexResult < ( ) > {
277- let array = PrimitiveArray :: empty :: < f64 > ( Nullability :: NonNullable ) . into_array ( ) ;
274+ #[ rstest]
275+ #[ case:: primitive( PrimitiveArray :: empty:: <f64 >( Nullability :: NonNullable ) . into_array( ) ) ]
276+ #[ case:: constant( ConstantArray :: new( Scalar :: from( 42f64 ) , 0 ) . into_array( ) ) ]
277+ fn empty_chunk_preserves_counts ( #[ case] array : ArrayRef ) -> VortexResult < ( ) > {
278278 let requests = [
279279 NullCount . bind ( EmptyOptions ) ,
280280 NanCount . bind ( EmptyOptions ) ,
281281 UncompressedSizeInBytes . bind ( EmptyOptions ) ,
282+ Sum . bind ( NumericalAggregateOpts :: skip_nans ( ) ) ,
282283 Min . bind ( NumericalAggregateOpts :: skip_nans ( ) ) ,
283284 Max . bind ( NumericalAggregateOpts :: skip_nans ( ) ) ,
284285 IsConstant . bind ( EmptyOptions ) ,
@@ -297,9 +298,16 @@ fn empty_chunk_preserves_counts() -> VortexResult<()> {
297298 results. get_result( & requests[ 2 ] ) ,
298299 Precision :: Exact ( Scalar :: from( 0u64 ) )
299300 ) ;
300- for request in & requests[ 3 ..] {
301+ assert_eq ! (
302+ results. get_result( & requests[ 3 ] ) ,
303+ Precision :: Exact ( Scalar :: primitive( 0f64 , Nullability :: Nullable ) )
304+ ) ;
305+ for request in & requests[ 4 ..] {
301306 assert ! ( results. get_result( request) . is_absent( ) ) ;
302307 }
308+ for stat in [ Stat :: Min , Stat :: Max , Stat :: IsConstant , Stat :: IsSorted ] {
309+ assert ! ( array. statistics( ) . get( stat) . is_absent( ) ) ;
310+ }
303311 Ok ( ( ) )
304312}
305313
@@ -521,3 +529,27 @@ fn fused_min_max_reuses_exact_chunk_extrema() -> VortexResult<()> {
521529 ) ;
522530 Ok ( ( ) )
523531}
532+
533+ #[ rstest]
534+ #[ case:: min( vec![ Min . bind( NumericalAggregateOpts :: skip_nans( ) ) ] , vec![ 1 , 2 ] , vec![ Scalar :: primitive( 1i32 , Nullability :: Nullable ) ] ) ]
535+ #[ case:: max( vec![ Max . bind( NumericalAggregateOpts :: skip_nans( ) ) ] , vec![ 1 , 2 ] , vec![ Scalar :: primitive( 2i32 , Nullability :: Nullable ) ] ) ]
536+ #[ case:: fused( vec![ Min . bind( NumericalAggregateOpts :: skip_nans( ) ) , Max . bind( NumericalAggregateOpts :: skip_nans( ) ) ] , vec![ 1 , 2 ] , vec![ Scalar :: primitive( 1i32 , Nullability :: Nullable ) , Scalar :: primitive( 2i32 , Nullability :: Nullable ) ] ) ]
537+ #[ case:: constant( vec![ IsConstant . bind( EmptyOptions ) ] , vec![ 1 , 1 ] , vec![ Scalar :: from( true ) ] ) ]
538+ #[ case:: sorted( vec![ IsSorted . bind( IsSortedOptions { strict: false } ) ] , vec![ 1 , 2 ] , vec![ Scalar :: from( true ) ] ) ]
539+ #[ case:: strict_sorted( vec![ IsSorted . bind( IsSortedOptions { strict: true } ) ] , vec![ 1 , 2 ] , vec![ Scalar :: from( true ) ] ) ]
540+ fn empty_constants_do_not_add_values_or_boundaries (
541+ #[ case] requests : Vec < AggregateFnRef > ,
542+ #[ case] values : Vec < i32 > ,
543+ #[ case] expected : Vec < Scalar > ,
544+ ) -> VortexResult < ( ) > {
545+ let chunks = [
546+ ConstantArray :: new ( Scalar :: from ( 42i32 ) , 0 ) . into_array ( ) ,
547+ PrimitiveArray :: from_iter ( values) . into_array ( ) ,
548+ ConstantArray :: new ( Scalar :: from ( -42i32 ) , 0 ) . into_array ( ) ,
549+ ] ;
550+ let results = accumulate ( chunks[ 0 ] . dtype ( ) , & requests, & chunks, 64 ) ?;
551+ for ( request, expected) in requests. iter ( ) . zip ( expected) {
552+ assert_eq ! ( results. get_result( request) , Precision :: Exact ( expected) ) ;
553+ }
554+ Ok ( ( ) )
555+ }
0 commit comments