use std::any::Any;
use std::sync::Arc;
use crate::error::Result;
use crate::logical_plan::Expr;
use crate::physical_plan::ExecutionPlan;
use crate::{arrow::datatypes::SchemaRef, scalar::ScalarValue};
#[derive(Debug, Clone, Default)]
pub struct Statistics {
pub num_rows: Option<usize>,
pub total_byte_size: Option<usize>,
pub column_statistics: Option<Vec<ColumnStatistics>>,
}
#[derive(Clone, Debug, PartialEq)]
pub struct ColumnStatistics {
pub null_count: Option<usize>,
pub max_value: Option<ScalarValue>,
pub min_value: Option<ScalarValue>,
pub distinct_count: Option<usize>,
}
#[derive(Debug, Clone)]
pub enum TableProviderFilterPushDown {
Unsupported,
Inexact,
Exact,
}
pub trait TableProvider: Sync + Send {
fn as_any(&self) -> &dyn Any;
fn schema(&self) -> SchemaRef;
fn scan(
&self,
projection: &Option<Vec<usize>>,
batch_size: usize,
filters: &[Expr],
limit: Option<usize>,
) -> Result<Arc<dyn ExecutionPlan>>;
fn statistics(&self) -> Statistics;
fn supports_filter_pushdown(
&self,
_filter: &Expr,
) -> Result<TableProviderFilterPushDown> {
Ok(TableProviderFilterPushDown::Unsupported)
}
}