From 6d34ce3804b510ffdbb0c095db60881266dfb90a Mon Sep 17 00:00:00 2001 From: liurenjie1024 Date: Fri, 25 Apr 2025 11:09:48 +0800 Subject: [PATCH 1/3] Add catalog builder trait --- crates/iceberg/src/catalog/mod.rs | 17 +++++++++++++++++ crates/iceberg/src/lib.rs | 5 +---- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/crates/iceberg/src/catalog/mod.rs b/crates/iceberg/src/catalog/mod.rs index 6a1572a4af..cf0340db3d 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,22 @@ pub trait Catalog: Debug + Sync + Send { async fn update_table(&self, commit: TableCommit) -> Result; } +/// 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) -> Self; + /// Configure uri of the catalog. + fn uri(self, uri: impl Into) -> Self; + /// Configure warehouse location of the catalog. + fn warehouse(self, warehouse: impl Into) -> Self; + /// Configure properties of the catalog. + fn with_prop(self, key: impl Into, value: impl Into) -> Self; + /// Create the catalog + fn build(self) -> impl Future>; +} + /// 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 556ff3e02f..f94b2b113e 100644 --- a/crates/iceberg/src/lib.rs +++ b/crates/iceberg/src/lib.rs @@ -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; From 6969f68118229aea4b33a43e6137b3579b4eb723 Mon Sep 17 00:00:00 2001 From: liurenjie1024 Date: Thu, 29 May 2025 17:08:21 +0800 Subject: [PATCH 2/3] More concise --- crates/iceberg/src/catalog/mod.rs | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/crates/iceberg/src/catalog/mod.rs b/crates/iceberg/src/catalog/mod.rs index cf0340db3d..9ed6e758c6 100644 --- a/crates/iceberg/src/catalog/mod.rs +++ b/crates/iceberg/src/catalog/mod.rs @@ -101,16 +101,8 @@ pub trait Catalog: Debug + Sync + Send { 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) -> Self; - /// Configure uri of the catalog. - fn uri(self, uri: impl Into) -> Self; - /// Configure warehouse location of the catalog. - fn warehouse(self, warehouse: impl Into) -> Self; - /// Configure properties of the catalog. - fn with_prop(self, key: impl Into, value: impl Into) -> Self; - /// Create the catalog - fn build(self) -> impl Future>; + /// Create a new catalog instance. + fn load(self, name: impl Into, props: HashMap) -> impl Future> + Send; } /// NamespaceIdent represents the identifier of a namespace in the catalog. From 56b3f8f815f173e5f2f71e66c4d35d82d2912ba7 Mon Sep 17 00:00:00 2001 From: liurenjie1024 Date: Thu, 29 May 2025 17:20:18 +0800 Subject: [PATCH 3/3] Format --- Cargo.lock | 2 +- crates/iceberg/src/catalog/mod.rs | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index c120f53896..6528d13f65 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3712,7 +3712,7 @@ dependencies = [ "iceberg-catalog-rest", "iceberg-datafusion", "iceberg_test_utils", - "ordered-float 4.6.0", + "ordered-float 2.10.1", "parquet", "tokio", "uuid", diff --git a/crates/iceberg/src/catalog/mod.rs b/crates/iceberg/src/catalog/mod.rs index 47d7e04239..5cfbae2056 100644 --- a/crates/iceberg/src/catalog/mod.rs +++ b/crates/iceberg/src/catalog/mod.rs @@ -102,7 +102,11 @@ 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, props: HashMap) -> impl Future> + Send; + fn load( + self, + name: impl Into, + props: HashMap, + ) -> impl Future> + Send; } /// NamespaceIdent represents the identifier of a namespace in the catalog.