alamb commented on code in PR #15645: URL: https://github.com/apache/datafusion/pull/15645#discussion_r2034037213
########## datafusion/common/src/stats.rs: ########## @@ -414,6 +414,53 @@ impl Statistics { self.total_byte_size = Precision::Absent; Ok(self) } + + /// Summarize zero or more statistics into a single `Statistics` instance. + pub fn merge_iter<'a, I>(items: I, schema: &Schema) -> Statistics + where + I: IntoIterator<Item = &'a Statistics>, + { + let mut items = items.into_iter(); + + let Some(init) = items.next() else { + return Statistics::new_unknown(schema); + }; + + items.fold(init.clone(), |acc: Statistics, item_stats: &Statistics| { + acc.merge(item_stats) + }) + } + + /// Merge this Statistics value with another Statistics value. Review Comment: This is the core logic for merging statistics code. -- 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: github-unsubscr...@datafusion.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: github-unsubscr...@datafusion.apache.org For additional commands, e-mail: github-h...@datafusion.apache.org