Skip to content
Merged
Changes from all commits
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
22 changes: 22 additions & 0 deletions crates/iceberg/src/transaction/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,12 @@ impl<'a> Transaction<'a> {
Ok(self)
}

/// Set the location of table
pub fn set_location(mut self, location: String) -> Result<Self> {
self.apply(vec![TableUpdate::SetLocation { location }], vec![])?;
Ok(self)
}

/// Commit transaction.
pub async fn commit(self, catalog: &dyn Catalog) -> Result<Table> {
let table_commit = TableCommit::builder()
Expand Down Expand Up @@ -335,6 +341,22 @@ mod tests {
);
}

#[test]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we make a integration test to make sure SetLocation works after the commit?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe we do not have one yet

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this makes sense, many transaction APIs lack an integ test to verify them. I've created this issue to track the task of adding this integ test: #1322

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() {
let table = make_v1_table();
Expand Down
Loading