Skip to content

Add catalog builder trait #1261

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions crates/iceberg/src/catalog/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

use std::collections::HashMap;
use std::fmt::{Debug, Display};
use std::future::Future;
use std::mem::take;
use std::ops::Deref;

Expand Down Expand Up @@ -96,6 +97,22 @@ pub trait Catalog: Debug + Sync + Send {
async fn update_table(&self, commit: TableCommit) -> Result<Table>;
}

/// Common interface for all catalog builders.
pub trait CatalogBuilder: Default + Debug + Send + Sync {
/// The catalog type that this builder creates.
type C: Catalog;
/// Configure name of the catalog.
fn name(self, name: impl Into<String>) -> Self;
/// Configure uri of the catalog.
fn uri(self, uri: impl Into<String>) -> Self;
/// Configure warehouse location of the catalog.
fn warehouse(self, warehouse: impl Into<String>) -> Self;
/// Configure properties of the catalog.
fn with_prop(self, key: impl Into<String>, value: impl Into<String>) -> Self;
/// Create the catalog
fn build(self) -> impl Future<Output = Result<Self::C>>;
}

/// NamespaceIdent represents the identifier of a namespace in the catalog.
///
/// The namespace identifier is a list of strings, where each string is a
Expand Down
5 changes: 1 addition & 4 deletions crates/iceberg/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,7 @@ pub use error::{Error, ErrorKind, Result};

mod catalog;

pub use catalog::{
Catalog, Namespace, NamespaceIdent, TableCommit, TableCreation, TableIdent, TableRequirement,
TableUpdate, ViewCreation,
};
pub use catalog::*;

pub mod table;

Expand Down
Loading