Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
remove optional builder
  • Loading branch information
xanderbailey committed Jul 9, 2026
commit 797890a35b7659222df3e4308d8a4a8e1c3f6d0a
30 changes: 18 additions & 12 deletions crates/catalog/glue/src/catalog.rs
Original file line number Diff line number Diff line change
Expand Up @@ -293,17 +293,19 @@ impl GlueCatalog {

let metadata = TableMetadata::read_from(&self.file_io, &metadata_location).await?;

let table = Table::builder()
let mut builder = Table::builder()
.file_io(self.file_io())
.metadata_location(metadata_location)
.metadata(metadata)
.identifier(TableIdent::new(
NamespaceIdent::new(db_name),
table_name.to_owned(),
))
.runtime(self.runtime.clone())
.kms_client(self.kms_client.clone())
.build()?;
.runtime(self.runtime.clone());
if let Some(kms_client) = self.kms_client.clone() {
builder = builder.kms_client(kms_client);
}
let table = builder.build()?;

Ok((table, version_id))
}
Expand Down Expand Up @@ -654,14 +656,16 @@ impl Catalog for GlueCatalog {

builder.send().await.map_err(from_aws_sdk_error)?;

Table::builder()
let mut builder = Table::builder()
.file_io(self.file_io())
.metadata_location(metadata_location_str)
.metadata(metadata)
.identifier(TableIdent::new(NamespaceIdent::new(db_name), table_name))
.runtime(self.runtime.clone())
.kms_client(self.kms_client.clone())
.build()
.runtime(self.runtime.clone());
if let Some(kms_client) = self.kms_client.clone() {
builder = builder.kms_client(kms_client);
}
builder.build()
}

/// Loads a table from the Glue Catalog and constructs a `Table` object
Expand Down Expand Up @@ -885,14 +889,16 @@ impl Catalog for GlueCatalog {
.with_source(anyhow!("aws sdk error: {error:?}"))
})?;

Ok(Table::builder()
let mut builder = Table::builder()
.identifier(table_ident.clone())
.metadata_location(metadata_location)
.metadata(metadata)
.file_io(self.file_io())
.runtime(self.runtime.clone())
.kms_client(self.kms_client.clone())
.build()?)
.runtime(self.runtime.clone());
if let Some(kms_client) = self.kms_client.clone() {
builder = builder.kms_client(kms_client);
}
Ok(builder.build()?)
}

async fn update_table(&self, commit: TableCommit) -> Result<Table> {
Expand Down
20 changes: 12 additions & 8 deletions crates/catalog/hms/src/catalog.rs
Original file line number Diff line number Diff line change
Expand Up @@ -553,14 +553,16 @@ impl Catalog for HmsCatalog {
.await
.map_err(from_thrift_error)?;

Table::builder()
let mut builder = Table::builder()
.file_io(self.file_io())
.metadata_location(metadata_location_str)
.metadata(metadata)
.identifier(TableIdent::new(NamespaceIdent::new(db_name), table_name))
.runtime(self.runtime.clone())
.kms_client(self.kms_client.clone())
.build()
.runtime(self.runtime.clone());
if let Some(kms_client) = self.kms_client.clone() {
builder = builder.kms_client(kms_client);
}
builder.build()
}

/// Loads a table from the Hive Metastore and constructs a `Table` object
Expand Down Expand Up @@ -590,17 +592,19 @@ impl Catalog for HmsCatalog {

let metadata = TableMetadata::read_from(&self.file_io, &metadata_location).await?;

Table::builder()
let mut builder = Table::builder()
.file_io(self.file_io())
.metadata_location(metadata_location)
.metadata(metadata)
.identifier(TableIdent::new(
NamespaceIdent::new(db_name),
table.name.clone(),
))
.runtime(self.runtime.clone())
.kms_client(self.kms_client.clone())
.build()
.runtime(self.runtime.clone());
if let Some(kms_client) = self.kms_client.clone() {
builder = builder.kms_client(kms_client);
}
builder.build()
}

/// Asynchronously drops a table from the database.
Expand Down
36 changes: 22 additions & 14 deletions crates/catalog/rest/src/catalog.rs
Original file line number Diff line number Diff line change
Expand Up @@ -820,12 +820,14 @@ impl Catalog for RestCatalog {
.load_file_io(Some(metadata_location), Some(config))
.await?;

let table_builder = Table::builder()
let mut table_builder = Table::builder()
.identifier(table_ident.clone())
.file_io(file_io)
.metadata(response.metadata)
.runtime(self.runtime.clone())
.kms_client(self.kms_client.clone());
.runtime(self.runtime.clone());
if let Some(kms_client) = self.kms_client.clone() {
table_builder = table_builder.kms_client(kms_client);
}

if let Some(metadata_location) = response.metadata_location {
table_builder.metadata_location(metadata_location).build()
Expand Down Expand Up @@ -878,12 +880,14 @@ impl Catalog for RestCatalog {
.load_file_io(response.metadata_location.as_deref(), Some(config))
.await?;

let table_builder = Table::builder()
let mut table_builder = Table::builder()
.identifier(table_ident.clone())
.file_io(file_io)
.metadata(response.metadata)
.runtime(self.runtime.clone())
.kms_client(self.kms_client.clone());
.runtime(self.runtime.clone());
if let Some(kms_client) = self.kms_client.clone() {
table_builder = table_builder.kms_client(kms_client);
}

if let Some(metadata_location) = response.metadata_location {
table_builder.metadata_location(metadata_location).build()
Expand Down Expand Up @@ -1014,14 +1018,16 @@ impl Catalog for RestCatalog {

let file_io = self.load_file_io(Some(metadata_location), None).await?;

Table::builder()
let mut table_builder = Table::builder()
.identifier(table_ident.clone())
.file_io(file_io)
.metadata(response.metadata)
.metadata_location(metadata_location.clone())
.runtime(self.runtime.clone())
.kms_client(self.kms_client.clone())
.build()
.runtime(self.runtime.clone());
if let Some(kms_client) = self.kms_client.clone() {
table_builder = table_builder.kms_client(kms_client);
}
table_builder.build()
}

async fn update_table(&self, mut commit: TableCommit) -> Result<Table> {
Expand Down Expand Up @@ -1088,14 +1094,16 @@ impl Catalog for RestCatalog {
.load_file_io(Some(&response.metadata_location), None)
.await?;

Table::builder()
let mut table_builder = Table::builder()
.identifier(commit.identifier().clone())
.file_io(file_io)
.metadata(response.metadata)
.metadata_location(response.metadata_location)
.runtime(self.runtime.clone())
.kms_client(self.kms_client.clone())
.build()
.runtime(self.runtime.clone());
if let Some(kms_client) = self.kms_client.clone() {
table_builder = table_builder.kms_client(kms_client);
}
table_builder.build()
}
}

Expand Down
20 changes: 12 additions & 8 deletions crates/catalog/s3tables/src/catalog.rs
Original file line number Diff line number Diff line change
Expand Up @@ -285,14 +285,16 @@ impl S3TablesCatalog {
})?;
let metadata = TableMetadata::read_from(&self.file_io, metadata_location).await?;

let table = Table::builder()
let mut builder = Table::builder()
.identifier(table_ident.clone())
.metadata(metadata)
.metadata_location(metadata_location)
.file_io(self.file_io.clone())
.runtime(self.runtime.clone())
.kms_client(self.kms_client.clone())
.build()?;
.runtime(self.runtime.clone());
if let Some(kms_client) = self.kms_client.clone() {
builder = builder.kms_client(kms_client);
}
let table = builder.build()?;
Ok((table, resp.version_token))
}
}
Expand Down Expand Up @@ -585,14 +587,16 @@ impl Catalog for S3TablesCatalog {
.await
.map_err(from_aws_sdk_error)?;

let table = Table::builder()
let mut builder = Table::builder()
.identifier(table_ident)
.metadata_location(metadata_location_str)
.metadata(metadata)
.file_io(self.file_io.clone())
.runtime(self.runtime.clone())
.kms_client(self.kms_client.clone())
.build()?;
.runtime(self.runtime.clone());
if let Some(kms_client) = self.kms_client.clone() {
builder = builder.kms_client(kms_client);
}
let table = builder.build()?;
Ok(table)
}

Expand Down
30 changes: 18 additions & 12 deletions crates/catalog/sql/src/catalog.rs
Original file line number Diff line number Diff line change
Expand Up @@ -833,14 +833,16 @@ impl Catalog for SqlCatalog {

let metadata = TableMetadata::read_from(&self.fileio, &tbl_metadata_location).await?;

Ok(Table::builder()
let mut builder = Table::builder()
.file_io(self.fileio.clone())
.identifier(identifier.clone())
.metadata_location(tbl_metadata_location)
.metadata(metadata)
.runtime(self.runtime.clone())
.kms_client(self.kms_client.clone())
.build()?)
.runtime(self.runtime.clone());
if let Some(kms_client) = self.kms_client.clone() {
builder = builder.kms_client(kms_client);
}
Ok(builder.build()?)
}

async fn create_table(
Expand Down Expand Up @@ -905,14 +907,16 @@ impl Catalog for SqlCatalog {
VALUES (?, ?, ?, ?, ?)
"), vec![Some(&self.name), Some(&namespace.join(".")), Some(&tbl_name.clone()), Some(&tbl_metadata_location_str), Some(CATALOG_FIELD_TABLE_RECORD_TYPE)], None).await?;

Ok(Table::builder()
let mut builder = Table::builder()
.file_io(self.fileio.clone())
.metadata_location(tbl_metadata_location_str)
.identifier(tbl_ident)
.metadata(tbl_metadata)
.runtime(self.runtime.clone())
.kms_client(self.kms_client.clone())
.build()?)
.runtime(self.runtime.clone());
if let Some(kms_client) = self.kms_client.clone() {
builder = builder.kms_client(kms_client);
}
Ok(builder.build()?)
}

async fn rename_table(&self, src: &TableIdent, dest: &TableIdent) -> Result<()> {
Expand Down Expand Up @@ -978,14 +982,16 @@ impl Catalog for SqlCatalog {
VALUES (?, ?, ?, ?, ?)
"), vec![Some(&self.name), Some(&namespace.join(".")), Some(&tbl_name), Some(&metadata_location), Some(CATALOG_FIELD_TABLE_RECORD_TYPE)], None).await?;

Ok(Table::builder()
let mut builder = Table::builder()
.identifier(table_ident.clone())
.metadata_location(metadata_location)
.metadata(metadata)
.file_io(self.fileio.clone())
.runtime(self.runtime.clone())
.kms_client(self.kms_client.clone())
.build()?)
.runtime(self.runtime.clone());
if let Some(kms_client) = self.kms_client.clone() {
builder = builder.kms_client(kms_client);
}
Ok(builder.build()?)
}

/// Updates an existing table within the SQL catalog.
Expand Down
2 changes: 1 addition & 1 deletion crates/iceberg/public-api.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3074,7 +3074,7 @@ pub fn iceberg::table::TableBuilder::cache_size_bytes(self, cache_size_bytes: u6
pub fn iceberg::table::TableBuilder::disable_cache(self) -> Self
pub fn iceberg::table::TableBuilder::file_io(self, file_io: iceberg::io::FileIO) -> Self
pub fn iceberg::table::TableBuilder::identifier(self, identifier: iceberg::TableIdent) -> Self
pub fn iceberg::table::TableBuilder::kms_client(self, kms_client: impl core::convert::Into<core::option::Option<alloc::sync::Arc<dyn iceberg::encryption::KeyManagementClient>>>) -> Self
pub fn iceberg::table::TableBuilder::kms_client(self, kms_client: alloc::sync::Arc<dyn iceberg::encryption::KeyManagementClient>) -> Self
pub fn iceberg::table::TableBuilder::metadata<T: core::convert::Into<iceberg::spec::TableMetadataRef>>(self, metadata: T) -> Self
pub fn iceberg::table::TableBuilder::metadata_location<T: core::convert::Into<alloc::string::String>>(self, metadata_location: T) -> Self
pub fn iceberg::table::TableBuilder::readonly(self, readonly: bool) -> Self
Expand Down
30 changes: 18 additions & 12 deletions crates/iceberg/src/catalog/memory/catalog.rs
Original file line number Diff line number Diff line change
Expand Up @@ -173,14 +173,16 @@ impl MemoryCatalog {
let metadata_location = root_namespace_state.get_existing_table_location(table_ident)?;
let metadata = TableMetadata::read_from(&self.file_io, metadata_location).await?;

Table::builder()
let mut builder = Table::builder()
.identifier(table_ident.clone())
.metadata(metadata)
.metadata_location(metadata_location.to_string())
.file_io(self.file_io.clone())
.runtime(self.runtime.clone())
.kms_client(self.kms_client.clone())
.build()
.runtime(self.runtime.clone());
if let Some(kms_client) = self.kms_client.clone() {
builder = builder.kms_client(kms_client);
}
builder.build()
}
}

Expand Down Expand Up @@ -329,14 +331,16 @@ impl Catalog for MemoryCatalog {

root_namespace_state.insert_new_table(&table_ident, metadata_location.to_string())?;

Table::builder()
let mut builder = Table::builder()
.file_io(self.file_io.clone())
.metadata_location(metadata_location.to_string())
.metadata(metadata)
.identifier(table_ident)
.runtime(self.runtime.clone())
.kms_client(self.kms_client.clone())
.build()
.runtime(self.runtime.clone());
if let Some(kms_client) = self.kms_client.clone() {
builder = builder.kms_client(kms_client);
}
builder.build()
}

/// Load table from the catalog.
Expand Down Expand Up @@ -397,14 +401,16 @@ impl Catalog for MemoryCatalog {

let metadata = TableMetadata::read_from(&self.file_io, &metadata_location).await?;

Table::builder()
let mut builder = Table::builder()
.file_io(self.file_io.clone())
.metadata_location(metadata_location)
.metadata(metadata)
.identifier(table_ident.clone())
.runtime(self.runtime.clone())
.kms_client(self.kms_client.clone())
.build()
.runtime(self.runtime.clone());
if let Some(kms_client) = self.kms_client.clone() {
builder = builder.kms_client(kms_client);
}
builder.build()
}

/// Update a table in the catalog.
Expand Down
11 changes: 3 additions & 8 deletions crates/iceberg/src/table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,14 +114,9 @@ impl TableBuilder {
/// [`KeyManagementClient`] must be provided here so the table can build
/// an [`EncryptionManager`]; otherwise [`Self::build`] will return an error.
///
/// Accepts either an `Arc<dyn KeyManagementClient>` or an
/// `Option<Arc<dyn KeyManagementClient>>`, so catalogs that hold an
/// optional client can forward it directly. Passing `None` is a no-op.
pub fn kms_client(
mut self,
kms_client: impl Into<Option<Arc<dyn KeyManagementClient>>>,
) -> Self {
self.kms_client = kms_client.into();
/// This is optional: simply don't call it when no client is available.
pub fn kms_client(mut self, kms_client: Arc<dyn KeyManagementClient>) -> Self {
self.kms_client = Some(kms_client);
self
}

Expand Down
Loading