From ba01f939a5d4c480a5914fb9f69ab4cc5618a1c6 Mon Sep 17 00:00:00 2001 From: TennyZhuang Date: Sun, 12 Jan 2025 16:45:04 +0800 Subject: [PATCH 1/3] feat(core): expose remove_snapshots at Transaction API --- crates/iceberg/src/catalog/mod.rs | 2 +- crates/iceberg/src/transaction.rs | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/crates/iceberg/src/catalog/mod.rs b/crates/iceberg/src/catalog/mod.rs index cbda6c905..f39310248 100644 --- a/crates/iceberg/src/catalog/mod.rs +++ b/crates/iceberg/src/catalog/mod.rs @@ -1557,7 +1557,7 @@ mod tests { 1, 2 ] -} +} "#; let update = TableUpdate::RemoveSnapshots { diff --git a/crates/iceberg/src/transaction.rs b/crates/iceberg/src/transaction.rs index cfd6a8381..9635c8266 100644 --- a/crates/iceberg/src/transaction.rs +++ b/crates/iceberg/src/transaction.rs @@ -130,6 +130,14 @@ impl<'a> Transaction<'a> { snapshot_id } + /// Remove snapshots from table. + pub fn remove_snapshots(&mut self, snapshot_ids: Vec) -> Result { + self.append_updates(vec![TableUpdate::RemoveSnapshots { + snapshot_ids: snapshot_ids, + }])?; + Ok(self) + } + /// Creates a fast append action. pub fn fast_append( self, From 1c352cfca9a6347ba0bb8533b6db729d1225ded1 Mon Sep 17 00:00:00 2001 From: TennyZhuang Date: Sun, 12 Jan 2025 17:01:34 +0800 Subject: [PATCH 2/3] fix compilation --- crates/iceberg/src/transaction.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/iceberg/src/transaction.rs b/crates/iceberg/src/transaction.rs index 9635c8266..facf4ea17 100644 --- a/crates/iceberg/src/transaction.rs +++ b/crates/iceberg/src/transaction.rs @@ -131,7 +131,7 @@ impl<'a> Transaction<'a> { } /// Remove snapshots from table. - pub fn remove_snapshots(&mut self, snapshot_ids: Vec) -> Result { + pub fn remove_snapshots(mut self, snapshot_ids: Vec) -> Result { self.append_updates(vec![TableUpdate::RemoveSnapshots { snapshot_ids: snapshot_ids, }])?; From 21c066f237a69ccf18db4e3fada7729b5b21b1b4 Mon Sep 17 00:00:00 2001 From: TennyZhuang Date: Sun, 12 Jan 2025 17:04:40 +0800 Subject: [PATCH 3/3] make clippy happy --- crates/iceberg/src/transaction.rs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/crates/iceberg/src/transaction.rs b/crates/iceberg/src/transaction.rs index facf4ea17..08c563ded 100644 --- a/crates/iceberg/src/transaction.rs +++ b/crates/iceberg/src/transaction.rs @@ -132,9 +132,7 @@ impl<'a> Transaction<'a> { /// Remove snapshots from table. pub fn remove_snapshots(mut self, snapshot_ids: Vec) -> Result { - self.append_updates(vec![TableUpdate::RemoveSnapshots { - snapshot_ids: snapshot_ids, - }])?; + self.append_updates(vec![TableUpdate::RemoveSnapshots { snapshot_ids }])?; Ok(self) }