@@ -16,6 +16,7 @@ use vortex_array::aggregate_fn::fns::all_non_null::AllNonNull;
1616use vortex_array:: aggregate_fn:: fns:: all_null:: AllNull ;
1717use vortex_array:: aggregate_fn:: fns:: bounded_max:: BOUNDED_MAX_BOUND ;
1818use vortex_array:: aggregate_fn:: fns:: bounded_max:: BoundedMax ;
19+ use vortex_array:: arrays:: BoolArray ;
1920use vortex_array:: arrays:: ConstantArray ;
2021use vortex_array:: arrays:: PrimitiveArray ;
2122use vortex_array:: arrays:: StructArray ;
@@ -84,7 +85,7 @@ impl ZoneMap {
8485 Ok ( unsafe { Self :: new_unchecked ( column_dtype, array, aggregate_fns, zone_len, row_count) } )
8586 }
8687
87- pub ( super ) unsafe fn new_unchecked (
88+ pub ( crate ) unsafe fn new_unchecked (
8889 column_dtype : DType ,
8990 array : StructArray ,
9091 aggregate_fns : Arc < [ AggregateFnRef ] > ,
@@ -144,19 +145,32 @@ impl ZoneMap {
144145 session : & VortexSession ,
145146 ) -> VortexResult < Mask > {
146147 let mut ctx = session. create_execution_ctx ( ) ;
147- let num_zones = self . array . len ( ) ;
148- let predicate = self . lower_stats ( predicate. clone ( ) ) ?;
148+ self . applied_predicate ( predicate) ?
149+ . null_as_false ( )
150+ . execute ( & mut ctx)
151+ }
149152
150- let array = self . array . clone ( ) . into_array ( ) ;
151- let applied = array. apply_bound ( & predicate) ?;
153+ /// Evaluates a pruning predicate while preserving unknown (null) proof values.
154+ pub ( crate ) fn evaluate (
155+ & self ,
156+ predicate : & BoundExpression ,
157+ session : & VortexSession ,
158+ ) -> VortexResult < BoolArray > {
159+ let mut ctx = session. create_execution_ctx ( ) ;
160+ self . applied_predicate ( predicate) ?
161+ . execute :: < BoolArray > ( & mut ctx)
162+ }
152163
164+ fn applied_predicate ( & self , predicate : & BoundExpression ) -> VortexResult < ArrayRef > {
165+ let num_zones = self . array . len ( ) ;
166+ let predicate = self . lower_stats ( predicate. clone ( ) ) ?;
167+ let applied = self . array . clone ( ) . into_array ( ) . apply_bound ( & predicate) ?;
153168 if !contains_row_count ( & applied) {
154- return applied . null_as_false ( ) . execute ( & mut ctx ) ;
169+ return Ok ( applied ) ;
155170 }
156171
157172 let row_count_array = row_count_array ( self . zone_len , self . row_count , num_zones) ?;
158- let substituted = substitute_row_count ( applied, & row_count_array) ?;
159- substituted. null_as_false ( ) . execute ( & mut ctx)
173+ substitute_row_count ( applied, & row_count_array)
160174 }
161175
162176 fn lower_stats ( & self , predicate : BoundExpression ) -> VortexResult < BoundExpression > {
0 commit comments