Skip to content

Commit 9f28472

Browse files
committed
address comments
1 parent 14eeb65 commit 9f28472

File tree

4 files changed

+20
-22
lines changed

4 files changed

+20
-22
lines changed

datafusion/datasource/src/file_groups.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -420,9 +420,14 @@ impl FileGroup {
420420
self.files.push(file);
421421
}
422422

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+
}
426431
}
427432

428433
/// Partition the list of files into `n` groups

datafusion/datasource/src/source.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ impl ExecutionPlan for DataSourceExec {
195195
self.data_source.as_any().downcast_ref::<FileScanConfig>()
196196
{
197197
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) {
199199
statistics = stat.clone();
200200
}
201201
}

datafusion/datasource/src/statistics.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -476,7 +476,7 @@ pub fn compute_all_files_statistics(
476476
// Then summary statistics across all file groups
477477
let file_groups_statistics = file_groups_with_stats
478478
.iter()
479-
.filter_map(|file_group| file_group.statistics_ref());
479+
.filter_map(|file_group| file_group.file_statistics(None));
480480

481481
let mut statistics =
482482
Statistics::try_merge_iter(file_groups_statistics, &table_schema)?;

datafusion/physical-plan/src/execution_plan.rs

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -435,25 +435,18 @@ pub trait ExecutionPlan: Debug + DisplayAs + Send + Sync {
435435
/// (the default), not an error.
436436
/// If `partition` is `None`, it returns statistics for the entire plan.
437437
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+
);
455447
}
456448
}
449+
Ok(Statistics::new_unknown(&self.schema()))
457450
}
458451

459452
/// Returns `true` if a limit can be safely pushed down through this

0 commit comments

Comments
 (0)