@@ -80,7 +80,7 @@ impl ComputeFnVTable for Take {
8080 // We know that constant array don't need stats propagation, so we can avoid the overhead of
8181 // computing derived stats and merging them in.
8282 if !taken_array. is_constant ( ) {
83- propagate_take_stats ( array, & taken_array) ?;
83+ propagate_take_stats ( array, & taken_array, indices ) ?;
8484 }
8585
8686 Ok ( taken_array. into ( ) )
@@ -111,12 +111,18 @@ impl ComputeFnVTable for Take {
111111 }
112112}
113113
114- fn propagate_take_stats ( source : & dyn Array , target : & dyn Array ) -> VortexResult < ( ) > {
114+ fn propagate_take_stats (
115+ source : & dyn Array ,
116+ target : & dyn Array ,
117+ indices : & dyn Array ,
118+ ) -> VortexResult < ( ) > {
115119 target. statistics ( ) . with_mut_typed_stats_set ( |mut st| {
116- let is_constant = source. statistics ( ) . get_as :: < bool > ( Stat :: IsConstant ) ;
117- if is_constant == Some ( Precision :: Exact ( true ) ) {
118- // Any combination of elements from a constant array is still const
119- st. set ( Stat :: IsConstant , Precision :: exact ( true ) ) ;
120+ if indices. all_valid ( ) {
121+ let is_constant = source. statistics ( ) . get_as :: < bool > ( Stat :: IsConstant ) ;
122+ if is_constant == Some ( Precision :: Exact ( true ) ) {
123+ // Any combination of elements from a constant array is still const
124+ st. set ( Stat :: IsConstant , Precision :: exact ( true ) ) ;
125+ }
120126 }
121127 let inexact_min_max = [ Stat :: Min , Stat :: Max ]
122128 . into_iter ( )
0 commit comments