From f3bb876b01b0d25780155de472a9843333922d93 Mon Sep 17 00:00:00 2001 From: Kynan Rilee Date: Wed, 19 Aug 2026 15:15:08 -0400 Subject: [PATCH] Claude: make Transaction::commit internals public --- crates/iceberg/public-api.txt | 22 ++++++++++++++++++--- crates/iceberg/src/catalog/mod.rs | 8 ++++---- crates/iceberg/src/transaction/action.rs | 11 +++++++++-- crates/iceberg/src/transaction/mod.rs | 2 +- crates/iceberg/src/transaction/row_delta.rs | 9 ++++++++- 5 files changed, 41 insertions(+), 11 deletions(-) diff --git a/crates/iceberg/public-api.txt b/crates/iceberg/public-api.txt index 91616c92b1..6eead1ddf1 100644 --- a/crates/iceberg/public-api.txt +++ b/crates/iceberg/public-api.txt @@ -3076,6 +3076,18 @@ pub fn iceberg::transaction::AddColumn::optional(name: impl alloc::string::ToStr pub fn iceberg::transaction::AddColumn::required(name: impl alloc::string::ToString, field_type: iceberg::spec::Type, initial_default: iceberg::spec::Literal) -> Self impl iceberg::transaction::AddColumn pub fn iceberg::transaction::AddColumn::builder() -> AddColumnBuilder<((), (), (), (), (), (), ())> +pub struct iceberg::transaction::RowDeltaAction +impl iceberg::transaction::RowDeltaAction +pub fn iceberg::transaction::RowDeltaAction::add_data_files(self, data_files: impl core::iter::traits::collect::IntoIterator) -> Self +pub fn iceberg::transaction::RowDeltaAction::add_delete_files(self, delete_files: impl core::iter::traits::collect::IntoIterator) -> Self +pub fn iceberg::transaction::RowDeltaAction::new() -> Self +pub fn iceberg::transaction::RowDeltaAction::set_commit_uuid(self, commit_uuid: uuid::Uuid) -> Self +pub fn iceberg::transaction::RowDeltaAction::set_snapshot_properties(self, snapshot_properties: std::collections::hash::map::HashMap) -> Self +pub fn iceberg::transaction::RowDeltaAction::with_check_duplicate(self, v: bool) -> Self +impl core::default::Default for iceberg::transaction::RowDeltaAction +pub fn iceberg::transaction::RowDeltaAction::default() -> Self +impl iceberg::transaction::TransactionAction for iceberg::transaction::RowDeltaAction +pub fn iceberg::transaction::RowDeltaAction::commit<'life0, 'async_trait>(self: alloc::sync::Arc, table: &'life0 iceberg::table::Table) -> core::pin::Pin> + core::marker::Send + 'async_trait)>> where Self: 'async_trait, 'life0: 'async_trait pub struct iceberg::transaction::Transaction impl iceberg::transaction::Transaction pub async fn iceberg::transaction::Transaction::commit(self, catalog: &dyn iceberg::Catalog) -> iceberg::Result @@ -3083,7 +3095,7 @@ pub fn iceberg::transaction::Transaction::expire_snapshots(&self) -> iceberg::tr pub fn iceberg::transaction::Transaction::fast_append(&self) -> iceberg::transaction::append::FastAppendAction pub fn iceberg::transaction::Transaction::new(table: &iceberg::table::Table) -> Self pub fn iceberg::transaction::Transaction::replace_sort_order(&self) -> iceberg::transaction::sort_order::ReplaceSortOrderAction -pub fn iceberg::transaction::Transaction::row_delta(&self) -> iceberg::transaction::row_delta::RowDeltaAction +pub fn iceberg::transaction::Transaction::row_delta(&self) -> iceberg::transaction::RowDeltaAction pub fn iceberg::transaction::Transaction::update_location(&self) -> iceberg::transaction::update_location::UpdateLocationAction pub fn iceberg::transaction::Transaction::update_schema(&self) -> iceberg::transaction::update_schema::UpdateSchemaAction pub fn iceberg::transaction::Transaction::update_statistics(&self) -> iceberg::transaction::update_statistics::UpdateStatisticsAction @@ -3093,8 +3105,12 @@ impl core::clone::Clone for iceberg::transaction::Transaction pub fn iceberg::transaction::Transaction::clone(&self) -> iceberg::transaction::Transaction pub trait iceberg::transaction::ApplyTransactionAction pub fn iceberg::transaction::ApplyTransactionAction::apply(self, tx: iceberg::transaction::Transaction) -> iceberg::Result -impl iceberg::transaction::ApplyTransactionAction for T -pub fn T::apply(self, tx: iceberg::transaction::Transaction) -> iceberg::Result where Self: core::marker::Sized +impl iceberg::transaction::ApplyTransactionAction for T +pub fn T::apply(self, tx: iceberg::transaction::Transaction) -> core::result::Result +pub trait iceberg::transaction::TransactionAction: as_any::AsAny + core::marker::Sync + core::marker::Send +pub fn iceberg::transaction::TransactionAction::commit<'life0, 'async_trait>(self: alloc::sync::Arc, table: &'life0 iceberg::table::Table) -> core::pin::Pin> + core::marker::Send + 'async_trait)>> where Self: 'async_trait, 'life0: 'async_trait +impl iceberg::transaction::TransactionAction for iceberg::transaction::RowDeltaAction +pub fn iceberg::transaction::RowDeltaAction::commit<'life0, 'async_trait>(self: alloc::sync::Arc, table: &'life0 iceberg::table::Table) -> core::pin::Pin> + core::marker::Send + 'async_trait)>> where Self: 'async_trait, 'life0: 'async_trait pub mod iceberg::transform pub trait iceberg::transform::TransformFunction: core::marker::Send + core::marker::Sync + core::fmt::Debug pub fn iceberg::transform::TransformFunction::transform(&self, input: arrow_array::array::ArrayRef) -> iceberg::Result diff --git a/crates/iceberg/src/catalog/mod.rs b/crates/iceberg/src/catalog/mod.rs index 3ab0f2886b..aaf2ed13ca 100644 --- a/crates/iceberg/src/catalog/mod.rs +++ b/crates/iceberg/src/catalog/mod.rs @@ -343,11 +343,11 @@ pub struct TableCreation { /// TableCommit represents the commit of a table in the catalog. /// -/// The builder is marked as private since it's dangerous and error-prone to construct -/// [`TableCommit`] directly. -/// Users are supposed to use [`crate::transaction::Transaction`] to update table. +/// Most users should use [`crate::transaction::Transaction`] to update a table, +/// which builds this internally. Construct it directly only when managing the +/// commit yourself, from the updates and requirements produced by a +/// [`crate::transaction::TransactionAction`]. #[derive(Debug, TypedBuilder)] -#[builder(build_method(vis = "pub(crate)"))] pub struct TableCommit { /// The table ident. ident: TableIdent, diff --git a/crates/iceberg/src/transaction/action.rs b/crates/iceberg/src/transaction/action.rs index aa0a05d0d9..071b240c1f 100644 --- a/crates/iceberg/src/transaction/action.rs +++ b/crates/iceberg/src/transaction/action.rs @@ -34,9 +34,16 @@ pub(crate) type BoxedTransactionAction = Arc; /// Each action is responsible for generating the updates and requirements needed /// to modify the table metadata. #[async_trait] -pub(crate) trait TransactionAction: AsAny + Sync + Send { +pub trait TransactionAction: AsAny + Sync + Send { /// Commits this action against the provided table and returns the resulting updates. - /// NOTE: This function is intended for internal use only and should not be called directly by users. + /// NOTE: Most users should apply actions through [`Transaction`], which handles + /// rebasing onto the latest table state and retrying on commit conflicts. Call + /// this directly only to take over that responsibility yourself, passing the + /// resulting updates and requirements to [`Catalog::update_table`] via + /// [`TableCommit`]. + /// + /// [`Catalog::update_table`]: crate::Catalog::update_table + /// [`TableCommit`]: crate::TableCommit /// /// # Arguments /// diff --git a/crates/iceberg/src/transaction/mod.rs b/crates/iceberg/src/transaction/mod.rs index bdce9b0b56..5fa6dec0a7 100644 --- a/crates/iceberg/src/transaction/mod.rs +++ b/crates/iceberg/src/transaction/mod.rs @@ -56,6 +56,7 @@ pub use action::*; mod append; mod expire_snapshots; mod row_delta; +pub use row_delta::RowDeltaAction; mod snapshot; mod sort_order; mod update_location; @@ -76,7 +77,6 @@ use crate::table::Table; use crate::transaction::action::BoxedTransactionAction; use crate::transaction::append::FastAppendAction; use crate::transaction::expire_snapshots::ExpireSnapshotsAction; -use crate::transaction::row_delta::RowDeltaAction; use crate::transaction::sort_order::ReplaceSortOrderAction; use crate::transaction::update_location::UpdateLocationAction; use crate::transaction::update_properties::UpdatePropertiesAction; diff --git a/crates/iceberg/src/transaction/row_delta.rs b/crates/iceberg/src/transaction/row_delta.rs index 2b70cfbea3..7e62ce8320 100644 --- a/crates/iceberg/src/transaction/row_delta.rs +++ b/crates/iceberg/src/transaction/row_delta.rs @@ -61,8 +61,15 @@ pub struct RowDeltaAction { added_delete_files: Vec, } +impl Default for RowDeltaAction { + fn default() -> Self { + Self::new() + } +} + impl RowDeltaAction { - pub(crate) fn new() -> Self { + /// Create a new row delta action. Equivalent to [`crate::transaction::Transaction::row_delta`]. + pub fn new() -> Self { Self { check_duplicate: true, commit_uuid: None,