diff --git a/core/src/main/java/org/apache/iceberg/MergingSnapshotProducer.java b/core/src/main/java/org/apache/iceberg/MergingSnapshotProducer.java index f19305540e42..1e8f95fc363f 100644 --- a/core/src/main/java/org/apache/iceberg/MergingSnapshotProducer.java +++ b/core/src/main/java/org/apache/iceberg/MergingSnapshotProducer.java @@ -667,7 +667,7 @@ private ManifestFile createManifest(int specId, List bin) throws I return mergeManifests.get(bin); } - ManifestWriter writer = newManifestWriter(ops.current().spec()); + ManifestWriter writer = newManifestWriter(ops.current().specsById().get(specId)); try { for (ManifestFile manifest : bin) { try (ManifestReader reader = ManifestFiles.read(manifest, ops.io(), ops.current().specsById())) { @@ -676,11 +676,11 @@ private ManifestFile createManifest(int specId, List bin) throws I // suppress deletes from previous snapshots. only files deleted by this snapshot // should be added to the new manifest if (entry.snapshotId() == snapshotId()) { - writer.addEntry(entry); + writer.delete(entry); } } else if (entry.status() == Status.ADDED && entry.snapshotId() == snapshotId()) { // adds from this snapshot are still adds, otherwise they should be existing - writer.addEntry(entry); + writer.add(entry); } else { // add all files from the old manifest as existing files writer.existing(entry);