use std::any::Any;
use std::sync::Arc;
use async_trait::async_trait;
pub use datafusion_expr::{TableProviderFilterPushDown, TableType};
use crate::arrow::datatypes::SchemaRef;
use crate::error::Result;
use crate::execution::context::SessionState;
use crate::logical_plan::Expr;
use crate::physical_plan::ExecutionPlan;
#[async_trait]
pub trait TableProvider: Sync + Send {
fn as_any(&self) -> &dyn Any;
fn schema(&self) -> SchemaRef;
fn table_type(&self) -> TableType;
fn get_table_definition(&self) -> Option<&str> {
None
}
async fn scan(
&self,
ctx: &SessionState,
projection: &Option<Vec<usize>>,
filters: &[Expr],
limit: Option<usize>,
) -> Result<Arc<dyn ExecutionPlan>>;
fn supports_filter_pushdown(
&self,
_filter: &Expr,
) -> Result<TableProviderFilterPushDown> {
Ok(TableProviderFilterPushDown::Unsupported)
}
}
pub trait TableProviderFactory: Sync + Send {
fn create(&self, name: &str, url: &str) -> Arc<dyn TableProvider>;
}