xudong963 commented on code in PR #15432:
URL: https://github.com/apache/datafusion/pull/15432#discussion_r2019681642
##########
datafusion/core/src/datasource/statistics.rs:
##########
@@ -145,7 +147,142 @@ pub async fn get_statistics_with_limit(
Ok((result_files, statistics))
}
-fn add_row_stats(
+/// Generic function to compute statistics across multiple items that have
statistics
+fn compute_summary_statistics<T, I>(
+ items: I,
+ file_schema: &SchemaRef,
+ stats_extractor: impl Fn(&T) -> Option<&Statistics>,
+) -> Statistics
+where
+ I: IntoIterator<Item = T>,
+{
+ let size = file_schema.fields().len();
+ let mut col_stats_set = vec![ColumnStatistics::default(); size];
+ let mut num_rows = Precision::<usize>::Absent;
+ let mut total_byte_size = Precision::<usize>::Absent;
+
+ for (idx, item) in items.into_iter().enumerate() {
+ if let Some(item_stats) = stats_extractor(&item) {
+ if idx == 0 {
+ // First item, set values directly
+ num_rows = item_stats.num_rows;
+ total_byte_size = item_stats.total_byte_size;
+ for (index, column_stats) in
+ item_stats.column_statistics.iter().enumerate()
+ {
+ col_stats_set[index].null_count = column_stats.null_count;
Review Comment:
After trying, maybe can't avoid 😢
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]