MCPcopy Create free account
hub / github.com/apache/datafusion / with_statistics

Method with_statistics

datafusion/datasource/src/mod.rs:321–346  ·  view source on GitHub ↗

Update the statistics for this file. The provided `statistics` should cover only the file schema columns. This method will automatically append exact statistics for partition columns based on `partition_values`: - `min = max = partition_value` (all rows have the same value) - `null_count = 0` (partition values from paths are never null) - `distinct_count = 1` (all rows have the same partition val

(mut self, file_statistics: Arc<Statistics>)

Source from the content-addressed store, hash-verified

319 /// - `null_count = 0` (partition values from paths are never null)
320 /// - `distinct_count = 1` (all rows have the same partition value)
321 pub fn with_statistics(mut self, file_statistics: Arc<Statistics>) -> Self {
322 if self.partition_values.is_empty() {
323 // No partition columns, use stats as-is
324 self.statistics = Some(file_statistics);
325 } else {
326 // Extend stats with exact partition column statistics
327 let mut stats = Arc::unwrap_or_clone(file_statistics);
328 for partition_value in &self.partition_values {
329 let col_stats = ColumnStatistics {
330 null_count: Precision::Exact(0),
331 max_value: Precision::Exact(partition_value.clone()),
332 min_value: Precision::Exact(partition_value.clone()),
333 distinct_count: Precision::Exact(1),
334 sum_value: Precision::Absent,
335 byte_size: partition_value
336 .data_type()
337 .primitive_width()
338 .map(|w| stats.num_rows.multiply(&Precision::Exact(w)))
339 .unwrap_or_else(|| Precision::Absent),
340 };
341 stats.column_statistics.push(col_stats);
342 }
343 self.statistics = Some(Arc::new(stats));
344 }
345 self
346 }
347
348 /// Check if this file has any statistics.
349 /// This returns `true` if the file has any Exact or Inexact statistics

Calls 7

newFunction · 0.85
multiplyMethod · 0.80
is_emptyMethod · 0.45
cloneMethod · 0.45
mapMethod · 0.45
data_typeMethod · 0.45
pushMethod · 0.45