File tree 4 files changed +20
-22
lines changed
4 files changed +20
-22
lines changed Original file line number Diff line number Diff line change @@ -420,9 +420,14 @@ impl FileGroup {
420
420
self . files . push ( file) ;
421
421
}
422
422
423
- /// Get the statistics for this group
424
- pub fn statistics_ref ( & self ) -> Option < & Statistics > {
425
- self . statistics . as_deref ( )
423
+ /// Get the specific file statistics for the given index
424
+ /// If the index is None, return the `FileGroup` statistics
425
+ pub fn file_statistics ( & self , index : Option < usize > ) -> Option < & Statistics > {
426
+ if let Some ( index) = index {
427
+ self . files . get ( index) . and_then ( |f| f. statistics . as_deref ( ) )
428
+ } else {
429
+ self . statistics . as_deref ( )
430
+ }
426
431
}
427
432
428
433
/// Partition the list of files into `n` groups
Original file line number Diff line number Diff line change @@ -195,7 +195,7 @@ impl ExecutionPlan for DataSourceExec {
195
195
self . data_source . as_any ( ) . downcast_ref :: < FileScanConfig > ( )
196
196
{
197
197
if let Some ( file_group) = file_config. file_groups . get ( partition) {
198
- if let Some ( stat) = file_group. statistics_ref ( ) {
198
+ if let Some ( stat) = file_group. file_statistics ( None ) {
199
199
statistics = stat. clone ( ) ;
200
200
}
201
201
}
Original file line number Diff line number Diff line change @@ -476,7 +476,7 @@ pub fn compute_all_files_statistics(
476
476
// Then summary statistics across all file groups
477
477
let file_groups_statistics = file_groups_with_stats
478
478
. iter ( )
479
- . filter_map ( |file_group| file_group. statistics_ref ( ) ) ;
479
+ . filter_map ( |file_group| file_group. file_statistics ( None ) ) ;
480
480
481
481
let mut statistics =
482
482
Statistics :: try_merge_iter ( file_groups_statistics, & table_schema) ?;
Original file line number Diff line number Diff line change @@ -435,25 +435,18 @@ pub trait ExecutionPlan: Debug + DisplayAs + Send + Sync {
435
435
/// (the default), not an error.
436
436
/// If `partition` is `None`, it returns statistics for the entire plan.
437
437
fn partition_statistics ( & self , partition : Option < usize > ) -> Result < Statistics > {
438
- match partition {
439
- Some ( idx) => {
440
- // Validate partition index
441
- let partition_count = self . properties ( ) . partitioning . partition_count ( ) ;
442
- if idx >= partition_count {
443
- return internal_err ! (
444
- "Invalid partition index: {}, the partition count is {}" ,
445
- idx,
446
- partition_count
447
- ) ;
448
- }
449
- // Default implementation: return unknown statistics for the specific partition
450
- Ok ( Statistics :: new_unknown ( & self . schema ( ) ) )
451
- }
452
- None => {
453
- // Return unknown statistics for the entire plan
454
- Ok ( Statistics :: new_unknown ( & self . schema ( ) ) )
438
+ if let Some ( idx) = partition {
439
+ // Validate partition index
440
+ let partition_count = self . properties ( ) . partitioning . partition_count ( ) ;
441
+ if idx >= partition_count {
442
+ return internal_err ! (
443
+ "Invalid partition index: {}, the partition count is {}" ,
444
+ idx,
445
+ partition_count
446
+ ) ;
455
447
}
456
448
}
449
+ Ok ( Statistics :: new_unknown ( & self . schema ( ) ) )
457
450
}
458
451
459
452
/// Returns `true` if a limit can be safely pushed down through this
You can’t perform that action at this time.
0 commit comments