This is an automated email from the ASF dual-hosted git repository.
liurenjie1024 pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/iceberg-rust.git
The following commit(s) were added to refs/heads/main by this push:
new e8371de4 Add catalog builder trait (#1261)
e8371de4 is described below
commit e8371de4f78209c63fa996cad396efa14d720a68
Author: Renjie Liu <[email protected]>
AuthorDate: Fri Jun 6 16:24:09 2025 +0800
Add catalog builder trait (#1261)
## Which issue does this PR close?
- Closes #1254 .
## What changes are included in this PR?
Add `CatalogBuilder` trait.
## Are these changes tested?
No, empty trait def.
---
crates/iceberg/src/catalog/mod.rs | 13 +++++++++++++
crates/iceberg/src/lib.rs | 5 +----
2 files changed, 14 insertions(+), 4 deletions(-)
diff --git a/crates/iceberg/src/catalog/mod.rs
b/crates/iceberg/src/catalog/mod.rs
index 3457f836..5cfbae20 100644
--- a/crates/iceberg/src/catalog/mod.rs
+++ b/crates/iceberg/src/catalog/mod.rs
@@ -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;
@@ -96,6 +97,18 @@ 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;
+ /// Create a new catalog instance.
+ fn load(
+ self,
+ name: impl Into<String>,
+ props: HashMap<String, String>,
+ ) -> impl Future<Output = Result<Self::C>> + Send;
+}
+
/// NamespaceIdent represents the identifier of a namespace in the catalog.
///
/// The namespace identifier is a list of strings, where each string is a
diff --git a/crates/iceberg/src/lib.rs b/crates/iceberg/src/lib.rs
index 6de20389..06e39156 100644
--- a/crates/iceberg/src/lib.rs
+++ b/crates/iceberg/src/lib.rs
@@ -64,10 +64,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;