Skip to content

Commit 797bf15

Browse files
Avoid removing snapshots and data files
1 parent 129c819 commit 797bf15

2 files changed

Lines changed: 0 additions & 29 deletions

File tree

iceberg-rust/src/table/transaction/mod.rs

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@ use crate::{catalog::commit::CommitTable, error::Error, table::Table};
2323

2424
use self::operation::Operation;
2525

26-
use super::delete_all_table_files;
27-
2826
pub(crate) mod append;
2927
pub(crate) mod operation;
3028

@@ -333,25 +331,8 @@ impl<'table> TableTransaction<'table> {
333331
/// ```
334332
pub async fn commit(self) -> Result<(), Error> {
335333
let catalog = self.table.catalog();
336-
let object_store = self.table.object_store();
337334
let identifier = self.table.identifier.clone();
338335

339-
// Save old metadata to be able to remove old data after a rewrite operation
340-
let delete_data = if self.operations.values().any(|x| {
341-
matches!(
342-
x,
343-
Operation::Replace {
344-
branch: _,
345-
files: _,
346-
additional_summary: _,
347-
}
348-
)
349-
}) {
350-
Some(self.table.metadata())
351-
} else {
352-
None
353-
};
354-
355336
// Execute the table operations
356337
let (mut requirements, mut updates) = (Vec::new(), Vec::new());
357338
for operation in self.operations.into_values() {
@@ -374,10 +355,6 @@ impl<'table> TableTransaction<'table> {
374355
})
375356
.await?;
376357

377-
if let Some(old_metadata) = delete_data {
378-
delete_all_table_files(old_metadata, object_store).await?;
379-
}
380-
381358
*self.table = new_table;
382359
Ok(())
383360
}

iceberg-rust/src/table/transaction/operation.rs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -521,18 +521,12 @@ impl Operation {
521521
.build()
522522
.map_err(iceberg_rust_spec::error::Error::from)?;
523523

524-
let old_snapshot_ids: Vec<i64> =
525-
table_metadata.snapshots.keys().map(Clone::clone).collect();
526-
527524
Ok((
528525
old_snapshot.map(|x| TableRequirement::AssertRefSnapshotId {
529526
r#ref: branch.clone().unwrap_or("main".to_owned()),
530527
snapshot_id: *x.snapshot_id(),
531528
}),
532529
vec![
533-
TableUpdate::RemoveSnapshots {
534-
snapshot_ids: old_snapshot_ids,
535-
},
536530
TableUpdate::AddSnapshot { snapshot },
537531
TableUpdate::SetSnapshotRef {
538532
ref_name: branch.unwrap_or("main".to_owned()),

0 commit comments

Comments
 (0)