@@ -16,14 +16,14 @@ use crate::aggregate_fn::AggregateFnRef;
1616use crate :: arrays:: ConstantArray ;
1717use crate :: dtype:: DType ;
1818use crate :: expr:: Expression ;
19+ use crate :: expr:: stats:: Stat ;
1920use crate :: expr:: stats:: StatsProvider ;
2021use crate :: scalar:: Scalar ;
2122use crate :: scalar_fn:: Arity ;
2223use crate :: scalar_fn:: ChildName ;
2324use crate :: scalar_fn:: ExecutionArgs ;
2425use crate :: scalar_fn:: ScalarFnId ;
2526use crate :: scalar_fn:: ScalarFnVTable ;
26- use crate :: stats:: legacy:: legacy_stat_for_aggregate;
2727
2828/// Options for the `stat` scalar function.
2929#[ derive( Clone , Debug , PartialEq , Eq , Hash ) ]
@@ -133,15 +133,20 @@ fn stat_array(
133133 dtype : DType ,
134134 len : usize ,
135135) -> VortexResult < ArrayRef > {
136- let value = legacy_stat_for_aggregate ( aggregate_fn)
137- . and_then ( |stat| {
138- array
139- . statistics ( )
140- . with_typed_stats_set ( |stats| stats. get ( stat) )
141- } )
142- // We don't mind whether the stat is approxed or not, since these are row-wise bounds
143- . map ( |stat| stat. into_inner ( ) )
144- . and_then ( Scalar :: into_value) ;
136+ let value = if let Some ( stat) = Stat :: from_aggregate_fn ( aggregate_fn) {
137+ array
138+ . statistics ( )
139+ . with_typed_stats_set ( |stats| stats. get ( stat) )
140+ // We don't mind whether the stat is approxed or not, since these are row-wise bounds.
141+ . map ( |stat| stat. into_inner ( ) )
142+ . and_then ( Scalar :: into_value)
143+ } else {
144+ tracing:: trace!(
145+ "No legacy Stat slot for aggregate {}; stat expression will resolve to null" ,
146+ aggregate_fn
147+ ) ;
148+ None
149+ } ;
145150
146151 let scalar = Scalar :: try_new ( dtype, value) ?;
147152 Ok ( ConstantArray :: new ( scalar, len) . into_array ( ) )
0 commit comments