use std::fmt::Debug;
use std::sync::Arc;
pub mod identifier;
pub mod namespace;
use iceberg_rust_spec::spec::materialized_view_metadata::MaterializedViewMetadata;
use iceberg_rust_spec::spec::table_metadata::TableMetadata;
use iceberg_rust_spec::spec::view_metadata::ViewMetadata;
use identifier::Identifier;
use object_store::ObjectStore;
use crate::error::Error;
use crate::materialized_view::MaterializedView;
use crate::table::Table;
use crate::view::View;
use self::bucket::Bucket;
use self::commit::{CommitTable, CommitView};
use self::namespace::Namespace;
use self::tabular::Tabular;
pub mod bucket;
pub mod commit;
pub mod tabular;
#[async_trait::async_trait]
pub trait Catalog: Send + Sync + Debug {
async fn list_tables(&self, namespace: &Namespace) -> Result<Vec<Identifier>, Error>;
async fn list_namespaces(&self, parent: Option<&str>) -> Result<Vec<Namespace>, Error>;
async fn table_exists(&self, identifier: &Identifier) -> Result<bool, Error>;
async fn drop_table(&self, identifier: &Identifier) -> Result<(), Error>;
async fn load_tabular(self: Arc<Self>, identifier: &Identifier) -> Result<Tabular, Error>;
async fn create_table(
self: Arc<Self>,
identifier: Identifier,
metadata: TableMetadata,
) -> Result<Table, Error>;
async fn create_view(
self: Arc<Self>,
identifier: Identifier,
metadata: ViewMetadata,
) -> Result<View, Error>;
async fn create_materialized_view(
self: Arc<Self>,
identifier: Identifier,
metadata: MaterializedViewMetadata,
) -> Result<MaterializedView, Error>;
async fn update_table(self: Arc<Self>, commit: CommitTable) -> Result<Table, Error>;
async fn update_view(self: Arc<Self>, commit: CommitView) -> Result<View, Error>;
async fn update_materialized_view(
self: Arc<Self>,
commit: CommitView,
) -> Result<MaterializedView, Error>;
fn object_store(&self, bucket: Bucket) -> Arc<dyn ObjectStore>;
}
#[async_trait::async_trait]
pub trait CatalogList: Send + Sync + Debug {
async fn catalog(&self, name: &str) -> Option<Arc<dyn Catalog>>;
async fn list_catalogs(&self) -> Vec<String>;
}