Skip to content

Commit 1373d7f

Browse files
authored
feat: Add API to set location in the transacation (#1317)
## Which issue does this PR close? - Closes #1316 ## What changes are included in this PR? - Added new API `set_location` in `transaction` ## Are these changes tested? - Added an unit test to cover the change
1 parent 8b7fa4e commit 1373d7f

File tree

1 file changed

+22
-0
lines changed
  • crates/iceberg/src/transaction

1 file changed

+22
-0
lines changed

crates/iceberg/src/transaction/mod.rs

+22
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,12 @@ impl<'a> Transaction<'a> {
183183
Ok(self)
184184
}
185185

186+
/// Set the location of table
187+
pub fn set_location(mut self, location: String) -> Result<Self> {
188+
self.apply(vec![TableUpdate::SetLocation { location }], vec![])?;
189+
Ok(self)
190+
}
191+
186192
/// Commit transaction.
187193
pub async fn commit(self, catalog: &dyn Catalog) -> Result<Table> {
188194
let table_commit = TableCommit::builder()
@@ -335,6 +341,22 @@ mod tests {
335341
);
336342
}
337343

344+
#[test]
345+
fn test_set_location() {
346+
let table = make_v2_table();
347+
let tx = Transaction::new(&table);
348+
let tx = tx
349+
.set_location(String::from("s3://bucket/prefix/new_table"))
350+
.unwrap();
351+
352+
assert_eq!(
353+
vec![TableUpdate::SetLocation {
354+
location: String::from("s3://bucket/prefix/new_table")
355+
}],
356+
tx.updates
357+
)
358+
}
359+
338360
#[tokio::test]
339361
async fn test_transaction_apply_upgrade() {
340362
let table = make_v1_table();

0 commit comments

Comments
 (0)