diff --git a/crates/iceberg/src/transaction/overwrite.rs b/crates/iceberg/src/transaction/overwrite.rs index 76b2e299f7..791a6e3069 100644 --- a/crates/iceberg/src/transaction/overwrite.rs +++ b/crates/iceberg/src/transaction/overwrite.rs @@ -420,9 +420,10 @@ mod tests { let table = make_v3_minimal_table_in_catalog(&catalog).await; let spec_id = table.metadata().default_partition_spec_id(); - let original_file = test_data_file("test/original.parquet", spec_id); + let original_file1 = test_data_file("test/original1.parquet", spec_id); + let original_file2 = test_data_file("test/original2.parquet", spec_id); let tx = Transaction::new(&table); - let action = tx.fast_append().add_data_files(vec![original_file.clone()]); + let action = tx.fast_append().add_data_files(vec![original_file1.clone(), original_file2.clone()]); let tx = action.apply(tx).unwrap(); let table = tx.commit(&catalog).await.unwrap(); @@ -438,7 +439,7 @@ mod tests { let action = tx .overwrite() .add_data_files(vec![replacement_file.clone()]) - .delete_data_files(vec![original_file.clone()]); + .delete_data_files(vec![original_file1.clone(), original_file2.clone()]); let tx = action.apply(tx).unwrap(); let table = tx.commit(&catalog).await.unwrap(); @@ -460,13 +461,15 @@ mod tests { } } - assert!( - all_entries - .iter() - .any(|(status, path)| *status == ManifestStatus::Deleted - && path == "test/original.parquet"), - "Original file should be marked as Deleted, entries: {all_entries:?}", - ); + for original_file in ["test/original1.parquet", "test/original2.parquet"] { + assert!( + all_entries + .iter() + .any(|(status, path)| *status == ManifestStatus::Deleted + && path == original_file), + "Original file {original_file} should be marked as Deleted, entries: {all_entries:?}", + ); + } assert!( all_entries @@ -483,7 +486,7 @@ mod tests { .additional_properties .get("deleted-data-files") .map(|s| s.as_str()), - Some("1") + Some("2") ); assert_eq!( snapshot @@ -491,7 +494,7 @@ mod tests { .additional_properties .get("deleted-records") .map(|s| s.as_str()), - Some("1") + Some("2") ); // Step 3: Fast append after overwrite — delete-only manifest must survive. @@ -519,12 +522,14 @@ mod tests { } // The deleted entry must still be present after fast_append. - assert!( - all_entries - .iter() - .any(|(status, path)| *status == ManifestStatus::Deleted - && path == "test/original.parquet"), - "Deleted entry should survive fast_append, entries: {all_entries:?}", - ); + for original_file in ["test/original1.parquet", "test/original2.parquet"] { + assert!( + all_entries + .iter() + .any(|(status, path)| *status == ManifestStatus::Deleted + && path == original_file), + "Deleted entry should survive fast_append, entries: {all_entries:?}", + ); + } } } diff --git a/crates/iceberg/src/transaction/snapshot.rs b/crates/iceberg/src/transaction/snapshot.rs index c9d4da47ee..4424d802ed 100644 --- a/crates/iceberg/src/transaction/snapshot.rs +++ b/crates/iceberg/src/transaction/snapshot.rs @@ -398,10 +398,7 @@ impl<'a> SnapshotProducer<'a> { ); } - let previous_snapshot = table_metadata - .snapshot_by_id(self.snapshot_id) - .and_then(|snapshot| snapshot.parent_snapshot_id()) - .and_then(|parent_id| table_metadata.snapshot_by_id(parent_id)); + let previous_snapshot = table_metadata.current_snapshot(); let mut additional_properties = summary_collector.build(); additional_properties.extend(self.snapshot_properties.clone());