Apache DataFusion SQL Query Engine
Add TableProvider.statistics method (#3986)
Andy Grove4ea970d1bda5
diff --git a/datafusion/common/src/stats.rs b/datafusion/common/src/stats.rsindex c27f775320..d0f150a316 100644--- a/datafusion/common/src/stats.rs+++ b/datafusion/common/src/stats.rs@@ -15,11 +15,11 @@// specific language governing permissions and limitations// under the License.-//! This module provides an interface for plan level statistics.+//! This module provides data structures to represent statisticsuse crate::ScalarValue;-/// Statistics for a physical plan node+/// Statistics for a relation/// Fields are optional and can be inexact because the sources/// sometimes provide approximate estimates for performance reasons/// and the transformations output are not always predictable.@@ -37,7 +37,7 @@ pub struct Statistics {pub is_exact: bool,}-/// This table statistics are estimates about column+/// Statistics for a column within a relation#[derive(Clone, Debug, Default, PartialEq, Eq)]pub struct ColumnStatistics {/// Number of null values on columndiff --git a/datafusion/core/src/datasource/datasource.rs b/datafusion/core/src/datasource/datasource.rsindex 38e3193c49..5b71c077fc 100644--- a/datafusion/core/src/datasource/datasource.rs+++ b/datafusion/core/src/datasource/datasource.rs@@ -21,6 +21,7 @@ use std::any::Any;use std::sync::Arc;use async_trait::async_trait;+use datafusion_common::Statistics;use datafusion_expr::LogicalPlan;pub use datafusion_expr::{TableProviderFilterPushDown, TableType};@@ -77,6 +78,11 @@ pub trait TableProvider: Sync + Send {) -> Result<TableProviderFilterPushDown> {Ok(TableProviderFilterPushDown::Unsupported)}++ /// Get statistics for this table, if available+ fn statistics(&self) -> Option<Statistics> {+ None+ }}/// A factory which creates [`TableProvider`]s at runtime given a URL.