Skip to content
Open
Show file tree
Hide file tree
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
43 changes: 24 additions & 19 deletions crates/iceberg/src/transaction/overwrite.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand All @@ -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();

Expand All @@ -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
Expand All @@ -483,15 +486,15 @@ mod tests {
.additional_properties
.get("deleted-data-files")
.map(|s| s.as_str()),
Some("1")
Some("2")
);
assert_eq!(
snapshot
.summary()
.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.
Expand Down Expand Up @@ -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:?}",
);
}
}
}
5 changes: 1 addition & 4 deletions crates/iceberg/src/transaction/snapshot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down