@@ -18,6 +18,7 @@ use vortex_array::aggregate_fn::fns::bounded_max::BOUNDED_MAX_BOUND;
1818use vortex_array:: aggregate_fn:: fns:: bounded_max:: BoundedMax ;
1919use vortex_array:: aggregate_fn:: fns:: sum:: Sum ;
2020use vortex_array:: aggregate_fn:: fns:: sum:: normalize_legacy_partial_array;
21+ use vortex_array:: arrays:: BoolArray ;
2122use vortex_array:: arrays:: ConstantArray ;
2223use vortex_array:: arrays:: PrimitiveArray ;
2324use vortex_array:: arrays:: StructArray ;
@@ -92,7 +93,7 @@ impl ZoneMap {
9293 Ok ( unsafe { Self :: new_unchecked ( column_dtype, array, aggregate_fns, zone_len, row_count) } )
9394 }
9495
95- pub ( super ) unsafe fn new_unchecked (
96+ pub ( crate ) unsafe fn new_unchecked (
9697 column_dtype : DType ,
9798 array : StructArray ,
9899 aggregate_fns : Arc < [ AggregateFnRef ] > ,
@@ -152,19 +153,32 @@ impl ZoneMap {
152153 session : & VortexSession ,
153154 ) -> VortexResult < Mask > {
154155 let mut ctx = session. create_execution_ctx ( ) ;
155- let num_zones = self . array . len ( ) ;
156- let predicate = self . lower_stats ( predicate. clone ( ) ) ?;
156+ self . applied_predicate ( predicate) ?
157+ . null_as_false ( )
158+ . execute ( & mut ctx)
159+ }
157160
158- let array = self . array . clone ( ) . into_array ( ) ;
159- let applied = array. apply_bound ( & predicate) ?;
161+ /// Evaluates a pruning predicate while preserving unknown (null) proof values.
162+ pub ( crate ) fn evaluate (
163+ & self ,
164+ predicate : & BoundExpression ,
165+ session : & VortexSession ,
166+ ) -> VortexResult < BoolArray > {
167+ let mut ctx = session. create_execution_ctx ( ) ;
168+ self . applied_predicate ( predicate) ?
169+ . execute :: < BoolArray > ( & mut ctx)
170+ }
160171
172+ fn applied_predicate ( & self , predicate : & BoundExpression ) -> VortexResult < ArrayRef > {
173+ let num_zones = self . array . len ( ) ;
174+ let predicate = self . lower_stats ( predicate. clone ( ) ) ?;
175+ let applied = self . array . clone ( ) . into_array ( ) . apply_bound ( & predicate) ?;
161176 if !contains_row_count ( & applied) {
162- return applied . null_as_false ( ) . execute ( & mut ctx ) ;
177+ return Ok ( applied ) ;
163178 }
164179
165180 let row_count_array = row_count_array ( self . zone_len , self . row_count , num_zones) ?;
166- let substituted = substitute_row_count ( applied, & row_count_array) ?;
167- substituted. null_as_false ( ) . execute ( & mut ctx)
181+ substitute_row_count ( applied, & row_count_array)
168182 }
169183
170184 fn lower_stats ( & self , predicate : BoundExpression ) -> VortexResult < BoundExpression > {
0 commit comments