(
file_group: FileGroup,
file_schema: SchemaRef,
collect_stats: bool,
)
| 467 | /// A new file group with summary statistics attached |
| 468 | #[expect(clippy::needless_pass_by_value)] |
| 469 | pub fn compute_file_group_statistics( |
| 470 | file_group: FileGroup, |
| 471 | file_schema: SchemaRef, |
| 472 | collect_stats: bool, |
| 473 | ) -> Result<FileGroup> { |
| 474 | if !collect_stats { |
| 475 | return Ok(file_group); |
| 476 | } |
| 477 | |
| 478 | let file_group_stats = file_group.iter().filter_map(|file| { |
| 479 | let stats = file.statistics.as_ref()?; |
| 480 | Some(stats.as_ref()) |
| 481 | }); |
| 482 | let statistics = Statistics::try_merge_iter_with_ndv_fallback( |
| 483 | file_group_stats, |
| 484 | &file_schema, |
| 485 | NdvFallback::Max, |
| 486 | )?; |
| 487 | |
| 488 | Ok(file_group.with_statistics(Arc::new(statistics))) |
| 489 | } |
| 490 | |
| 491 | /// Computes statistics for all files across multiple file groups. |
| 492 | /// |
searching dependent graphs…