use async_trait::async_trait;
use datafusion_common::{exec_err, DataFusionError};
use std::any::Any;
use std::fmt::Debug;
use std::sync::Arc;
use crate::table::TableProvider;
use datafusion_common::Result;
use datafusion_expr::TableType;
#[async_trait]
pub trait SchemaProvider: Debug + Sync + Send {
fn owner_name(&self) -> Option<&str> {
None
}
fn as_any(&self) -> &dyn Any;
fn table_names(&self) -> Vec<String>;
async fn table(
&self,
name: &str,
) -> Result<Option<Arc<dyn TableProvider>>, DataFusionError>;
async fn table_type(&self, name: &str) -> Result<Option<TableType>> {
self.table(name).await.map(|o| o.map(|t| t.table_type()))
}
#[allow(unused_variables)]
fn register_table(
&self,
name: String,
table: Arc<dyn TableProvider>,
) -> Result<Option<Arc<dyn TableProvider>>> {
exec_err!("schema provider does not support registering tables")
}
#[allow(unused_variables)]
fn deregister_table(&self, name: &str) -> Result<Option<Arc<dyn TableProvider>>> {
exec_err!("schema provider does not support deregistering tables")
}
fn table_exist(&self, name: &str) -> bool;
}