@@ -17,8 +17,11 @@ use crate::Columnar;
1717use crate :: ExecutionCtx ;
1818use crate :: IntoArray ;
1919use crate :: aggregate_fn:: AggregateFnId ;
20+ use crate :: aggregate_fn:: AggregateFnRef ;
21+ use crate :: aggregate_fn:: AggregateFnSatisfaction ;
2022use crate :: aggregate_fn:: AggregateFnVTable ;
2123use crate :: aggregate_fn:: EmptyOptions ;
24+ use crate :: aggregate_fn:: fns:: max:: Max ;
2225use crate :: aggregate_fn:: fns:: min_max:: MinMax ;
2326use crate :: aggregate_fn:: fns:: min_max:: min_max;
2427use crate :: dtype:: DType ;
@@ -115,6 +118,25 @@ impl AggregateFnVTable for BoundedMax {
115118 supported_dtype ( options, input_dtype) . map ( DType :: as_nullable)
116119 }
117120
121+ fn can_satisfy (
122+ & self ,
123+ options : & Self :: Options ,
124+ requested : & AggregateFnRef ,
125+ ) -> AggregateFnSatisfaction {
126+ if requested
127+ . as_opt :: < Self > ( )
128+ . is_some_and ( |other| other == options)
129+ {
130+ return AggregateFnSatisfaction :: Exact ;
131+ }
132+
133+ if requested. is :: < Self > ( ) || requested. is :: < Max > ( ) {
134+ AggregateFnSatisfaction :: Approximate
135+ } else {
136+ AggregateFnSatisfaction :: No
137+ }
138+ }
139+
118140 fn partial_dtype ( & self , options : & Self :: Options , input_dtype : & DType ) -> Option < DType > {
119141 self . return_dtype ( options, input_dtype)
120142 }
@@ -219,10 +241,15 @@ mod tests {
219241 use crate :: LEGACY_SESSION ;
220242 use crate :: VortexSessionExecute ;
221243 use crate :: aggregate_fn:: Accumulator ;
244+ use crate :: aggregate_fn:: AggregateFnSatisfaction ;
222245 use crate :: aggregate_fn:: AggregateFnVTable ;
246+ use crate :: aggregate_fn:: AggregateFnVTableExt ;
223247 use crate :: aggregate_fn:: DynAccumulator ;
248+ use crate :: aggregate_fn:: EmptyOptions ;
224249 use crate :: aggregate_fn:: fns:: bounded_max:: BoundedMax ;
225250 use crate :: aggregate_fn:: fns:: bounded_max:: BoundedMaxOptions ;
251+ use crate :: aggregate_fn:: fns:: max:: Max ;
252+ use crate :: aggregate_fn:: fns:: min:: Min ;
226253 use crate :: arrays:: PrimitiveArray ;
227254 use crate :: arrays:: VarBinViewArray ;
228255 use crate :: dtype:: Nullability ;
@@ -333,6 +360,33 @@ mod tests {
333360 Ok ( ( ) )
334361 }
335362
363+ #[ test]
364+ fn bounded_max_satisfies_max_bounds ( ) {
365+ let stored = BoundedMax . bind ( BoundedMaxOptions {
366+ max_bytes : max_bytes ( 5 ) ,
367+ } ) ;
368+ let same = BoundedMax . bind ( BoundedMaxOptions {
369+ max_bytes : max_bytes ( 5 ) ,
370+ } ) ;
371+ let other_bounded = BoundedMax . bind ( BoundedMaxOptions {
372+ max_bytes : max_bytes ( 6 ) ,
373+ } ) ;
374+
375+ assert_eq ! ( stored. can_satisfy( & same) , AggregateFnSatisfaction :: Exact ) ;
376+ assert_eq ! (
377+ stored. can_satisfy( & other_bounded) ,
378+ AggregateFnSatisfaction :: Approximate
379+ ) ;
380+ assert_eq ! (
381+ stored. can_satisfy( & Max . bind( EmptyOptions ) ) ,
382+ AggregateFnSatisfaction :: Approximate
383+ ) ;
384+ assert_eq ! (
385+ stored. can_satisfy( & Min . bind( EmptyOptions ) ) ,
386+ AggregateFnSatisfaction :: No
387+ ) ;
388+ }
389+
336390 #[ test]
337391 fn bounded_max_options_round_trip ( ) -> VortexResult < ( ) > {
338392 let options = BoundedMaxOptions {
0 commit comments