From 90dd90732445bd33043e8e1144865424948d4213 Mon Sep 17 00:00:00 2001 From: Shawn Chang Date: Mon, 12 May 2025 14:01:00 -0700 Subject: [PATCH 1/2] add api to set location in the transacation --- crates/iceberg/src/transaction/mod.rs | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/crates/iceberg/src/transaction/mod.rs b/crates/iceberg/src/transaction/mod.rs index 6ae25775b4..39ef87d41a 100644 --- a/crates/iceberg/src/transaction/mod.rs +++ b/crates/iceberg/src/transaction/mod.rs @@ -182,6 +182,15 @@ impl<'a> Transaction<'a> { )?; Ok(self) } + + /// Set the location of table + pub fn set_location(mut self, location: String) -> Result { + self.apply( + vec![TableUpdate::SetLocation { location }], + vec![], + )?; + Ok(self) + } /// Commit transaction. pub async fn commit(self, catalog: &dyn Catalog) -> Result { @@ -334,6 +343,22 @@ mod tests { tx.updates ); } + + #[test] + fn test_set_location() { + let table = make_v2_table(); + let tx = Transaction::new(&table); + let tx = tx + .set_location(String::from("s3://bucket/prefix/new_table")) + .unwrap(); + + assert_eq!( + vec![TableUpdate::SetLocation { + location: String::from("s3://bucket/prefix/new_table") + }], + tx.updates + ) + } #[tokio::test] async fn test_transaction_apply_upgrade() { From 3268fbe60b297706206e2aa1d83c4e9ce408ba78 Mon Sep 17 00:00:00 2001 From: Shawn Chang Date: Mon, 12 May 2025 14:21:13 -0700 Subject: [PATCH 2/2] format --- crates/iceberg/src/transaction/mod.rs | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/crates/iceberg/src/transaction/mod.rs b/crates/iceberg/src/transaction/mod.rs index 39ef87d41a..108ad10595 100644 --- a/crates/iceberg/src/transaction/mod.rs +++ b/crates/iceberg/src/transaction/mod.rs @@ -182,13 +182,10 @@ impl<'a> Transaction<'a> { )?; Ok(self) } - + /// Set the location of table pub fn set_location(mut self, location: String) -> Result { - self.apply( - vec![TableUpdate::SetLocation { location }], - vec![], - )?; + self.apply(vec![TableUpdate::SetLocation { location }], vec![])?; Ok(self) } @@ -343,7 +340,7 @@ mod tests { tx.updates ); } - + #[test] fn test_set_location() { let table = make_v2_table(); @@ -351,7 +348,7 @@ mod tests { let tx = tx .set_location(String::from("s3://bucket/prefix/new_table")) .unwrap(); - + assert_eq!( vec![TableUpdate::SetLocation { location: String::from("s3://bucket/prefix/new_table")