@@ -588,11 +588,24 @@ impl FileOpener for ParquetOpener {
588588 // metrics from the arrow reader itself
589589 let arrow_reader_metrics = ArrowReaderMetrics :: enabled ( ) ;
590590
591- // Compute bytes_per_row from file metadata for the bytes/sec metric.
591+ // Compute bytes_per_row from file metadata and feed it into the
592+ // selectivity tracker's running average (used by partition_filters_grouped).
592593 let bytes_per_row = compute_bytes_per_row (
593594 file_metadata. as_ref ( ) ,
594595 & projection. column_indices ( ) ,
595596 ) ;
597+ if let Some ( bpr) = bytes_per_row {
598+ let file_rows: u64 = file_metadata
599+ . row_groups ( )
600+ . iter ( )
601+ . map ( |rg| rg. num_rows ( ) as u64 )
602+ . sum ( ) ;
603+ if file_rows > 0 {
604+ selectivity_tracker
605+ . write ( )
606+ . update_bytes_per_row ( bpr, file_rows) ;
607+ }
608+ }
596609
597610 // Acquire tracker lock once for both partitioning and row filter building.
598611 let ( post_scan_filters, projection, mask) = {
@@ -611,7 +624,7 @@ impl FileOpener for ParquetOpener {
611624 . into_iter ( )
612625 . map ( Arc :: clone)
613626 . collect ( ) ;
614- tracker. partition_filters_grouped ( conjuncts, bytes_per_row )
627+ tracker. partition_filters_grouped ( conjuncts)
615628 } else {
616629 PartitionedFiltersGrouped {
617630 row_filter_groups : vec ! [ ] ,
@@ -623,18 +636,14 @@ impl FileOpener for ParquetOpener {
623636 // but don't add filter expressions as projection columns.
624637 let mut all_indices: Vec < usize > = projection. column_indices ( ) ;
625638 for filter in & post_scan {
626- for col in datafusion_physical_expr:: utils:: collect_columns ( filter)
627- {
639+ for col in datafusion_physical_expr:: utils:: collect_columns ( filter) {
628640 let idx = col. index ( ) ;
629641 if !all_indices. contains ( & idx) {
630642 all_indices. push ( idx) ;
631643 }
632644 }
633645 }
634- let mask = ProjectionMask :: roots (
635- builder. parquet_schema ( ) ,
636- all_indices,
637- ) ;
646+ let mask = ProjectionMask :: roots ( builder. parquet_schema ( ) , all_indices) ;
638647
639648 // Build row filter from groups of correlated filters
640649 if !row_filter_groups. is_empty ( ) {
0 commit comments