@@ -31,7 +31,7 @@ use arrow::{
3131use datafusion_common:: pruning:: PruningStatistics ;
3232use datafusion_common:: ScalarValue ;
3333use datafusion_physical_expr:: expressions:: NotExpr ;
34- use datafusion_physical_expr:: { split_conjunction, PhysicalExpr } ;
34+ use datafusion_physical_expr:: { split_conjunction, PhysicalExpr , PhysicalExprSimplifier } ;
3535use datafusion_pruning:: PruningPredicate ;
3636
3737use log:: { debug, trace} ;
@@ -325,7 +325,6 @@ impl PagePruningAccessPlanFilter {
325325 access_plan : ParquetAccessPlan ,
326326 limit : usize ,
327327 page_match_infos : & HashMap < usize , PageMatchInfo > ,
328- rg_metadata : & [ RowGroupMetaData ] ,
329328 file_metrics : & ParquetFileMetrics ,
330329 ) -> ParquetAccessPlan {
331330 if page_match_infos. is_empty ( ) {
@@ -370,7 +369,7 @@ impl PagePruningAccessPlanFilter {
370369 if total_fully_matched_rows >= limit {
371370 debug ! ( "Page limit pruning: found {total_fully_matched_rows} fully matched rows >= limit {limit}" ) ;
372371
373- let mut new_access_plan = ParquetAccessPlan :: new_none ( rg_metadata . len ( ) ) ;
372+ let mut new_access_plan = ParquetAccessPlan :: new_none ( access_plan . len ( ) ) ;
374373 let mut rows_selected = 0 ;
375374
376375 for ( rg_idx, page_indices, row_count) in fully_matched_info {
@@ -620,6 +619,10 @@ impl<'a> PagesPruningStatistics<'a> {
620619
621620 // Create inverted predicate
622621 let inverted_expr = Arc :: new ( NotExpr :: new ( pruning_predicate. orig_expr ( ) . clone ( ) ) ) ;
622+ // Simplify the NOT expression (e.g., NOT(c1 = 0) -> c1 != 0)
623+ // before building the pruning predicate
624+ let mut simplifier = PhysicalExprSimplifier :: new ( pruning_predicate. schema ( ) ) ;
625+ let inverted_expr = simplifier. simplify ( inverted_expr) . unwrap ( ) ;
623626 let inverted_predicate = match PruningPredicate :: try_new (
624627 inverted_expr,
625628 pruning_predicate. schema ( ) . clone ( ) ,
0 commit comments