@@ -19,14 +19,14 @@ use crate::arrays::ConstantArray;
1919use crate :: arrays:: chunked:: ChunkedArrayExt ;
2020use crate :: dtype:: DType ;
2121use crate :: expr:: Expression ;
22+ use crate :: expr:: stats:: Stat ;
2223use crate :: expr:: stats:: StatsProvider ;
2324use crate :: scalar:: Scalar ;
2425use crate :: scalar_fn:: Arity ;
2526use crate :: scalar_fn:: ChildName ;
2627use crate :: scalar_fn:: ExecutionArgs ;
2728use crate :: scalar_fn:: ScalarFnId ;
2829use crate :: scalar_fn:: ScalarFnVTable ;
29- use crate :: stats:: legacy:: legacy_stat_for_aggregate;
3030
3131/// Options for the `stat` scalar function.
3232#[ derive( Clone , Debug , PartialEq , Eq , Hash ) ]
@@ -156,15 +156,20 @@ fn stat_array(
156156 dtype : DType ,
157157 len : usize ,
158158) -> VortexResult < ArrayRef > {
159- let value = legacy_stat_for_aggregate ( aggregate_fn)
160- . and_then ( |stat| {
161- array
162- . statistics ( )
163- . with_typed_stats_set ( |stats| stats. get ( stat) )
164- } )
165- // We don't mind whether the stat is approxed or not, since these are row-wise bounds
166- . map ( |stat| stat. into_inner ( ) )
167- . and_then ( Scalar :: into_value) ;
159+ let value = if let Some ( stat) = Stat :: from_aggregate_fn ( aggregate_fn) {
160+ array
161+ . statistics ( )
162+ . with_typed_stats_set ( |stats| stats. get ( stat) )
163+ // We don't mind whether the stat is approxed or not, since these are row-wise bounds.
164+ . map ( |stat| stat. into_inner ( ) )
165+ . and_then ( Scalar :: into_value)
166+ } else {
167+ tracing:: trace!(
168+ "No legacy Stat slot for aggregate {}; stat expression will resolve to null" ,
169+ aggregate_fn
170+ ) ;
171+ None
172+ } ;
168173
169174 let scalar = Scalar :: try_new ( dtype, value) ?;
170175 Ok ( ConstantArray :: new ( scalar, len) . into_array ( ) )
0 commit comments