use crate::{Expr, LogicalPlan};
use arrow::datatypes::SchemaRef;
use datafusion_common::{Constraints, Result};
use std::any::Any;
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum TableProviderFilterPushDown {
Unsupported,
Inexact,
Exact,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum TableType {
Base,
View,
Temporary,
}
impl std::fmt::Display for TableType {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
TableType::Base => write!(f, "Base"),
TableType::View => write!(f, "View"),
TableType::Temporary => write!(f, "Temporary"),
}
}
}
pub trait TableSource: Sync + Send {
fn as_any(&self) -> &dyn Any;
fn schema(&self) -> SchemaRef;
fn constraints(&self) -> Option<&Constraints> {
None
}
fn table_type(&self) -> TableType {
TableType::Base
}
#[deprecated(since = "20.0.0", note = "use supports_filters_pushdown instead")]
fn supports_filter_pushdown(
&self,
_filter: &Expr,
) -> Result<TableProviderFilterPushDown> {
Ok(TableProviderFilterPushDown::Unsupported)
}
#[allow(deprecated)]
fn supports_filters_pushdown(
&self,
filters: &[&Expr],
) -> Result<Vec<TableProviderFilterPushDown>> {
filters
.iter()
.map(|f| self.supports_filter_pushdown(f))
.collect()
}
fn get_logical_plan(&self) -> Option<&LogicalPlan> {
None
}
fn get_column_default(&self, _column: &str) -> Option<&Expr> {
None
}
}