diff --git a/paimon-core/src/main/java/org/apache/paimon/iceberg/IcebergCommitCallback.java b/paimon-core/src/main/java/org/apache/paimon/iceberg/IcebergCommitCallback.java index 3852c7fb6eba..4378bab3c992 100644 --- a/paimon-core/src/main/java/org/apache/paimon/iceberg/IcebergCommitCallback.java +++ b/paimon-core/src/main/java/org/apache/paimon/iceberg/IcebergCommitCallback.java @@ -548,7 +548,8 @@ private void createMetadataWithBase( addedFiles, modifiedPartitions, baseDataManifestFileMetas, - snapshotId); + snapshotId, + snapshot.commitKind()); newDataManifestFileMetas = result.getLeft(); snapshotSummary = result.getRight(); } @@ -778,7 +779,8 @@ private List createNewlyAddedManifestFileMetas( Map> addedFiles, List modifiedPartitions, List baseManifestFileMetas, - long currentSnapshotId) + long currentSnapshotId, + Snapshot.CommitKind commitKind) throws IOException { IcebergSnapshotSummary snapshotSummary = IcebergSnapshotSummary.APPEND; List newManifestFileMetas = new ArrayList<>(); @@ -833,7 +835,10 @@ private List createNewlyAddedManifestFileMetas( newManifestFileMetas.add(fileMeta); } else { // some file is removed, rewrite this file meta - snapshotSummary = IcebergSnapshotSummary.OVERWRITE; + snapshotSummary = + commitKind == Snapshot.CommitKind.COMPACT + ? IcebergSnapshotSummary.REPLACE + : IcebergSnapshotSummary.OVERWRITE; List newEntries = new ArrayList<>(); for (IcebergManifestEntry entry : entries) { if (entry.isLive()) { diff --git a/paimon-core/src/main/java/org/apache/paimon/iceberg/metadata/IcebergSnapshotSummary.java b/paimon-core/src/main/java/org/apache/paimon/iceberg/metadata/IcebergSnapshotSummary.java index c8f64d4107d4..43a3e41536af 100644 --- a/paimon-core/src/main/java/org/apache/paimon/iceberg/metadata/IcebergSnapshotSummary.java +++ b/paimon-core/src/main/java/org/apache/paimon/iceberg/metadata/IcebergSnapshotSummary.java @@ -38,6 +38,7 @@ public class IcebergSnapshotSummary { public static final IcebergSnapshotSummary APPEND = new IcebergSnapshotSummary("append"); public static final IcebergSnapshotSummary OVERWRITE = new IcebergSnapshotSummary("overwrite"); + public static final IcebergSnapshotSummary REPLACE = new IcebergSnapshotSummary("replace"); private final Map summary; diff --git a/paimon-core/src/test/java/org/apache/paimon/iceberg/IcebergCompatibilityTest.java b/paimon-core/src/test/java/org/apache/paimon/iceberg/IcebergCompatibilityTest.java index a3f28f7ab408..2b5e794a57ab 100644 --- a/paimon-core/src/test/java/org/apache/paimon/iceberg/IcebergCompatibilityTest.java +++ b/paimon-core/src/test/java/org/apache/paimon/iceberg/IcebergCompatibilityTest.java @@ -185,6 +185,16 @@ private void testDeleteImpl(boolean deletionVector) throws Exception { // In dv mode, full compaction will remove all dv index and rewrite data files assertThat(getIcebergResult()).containsExactlyInAnyOrder("Record(2, 21)"); + FileIO fileIO = table.fileIO(); + long latestSnapshotId = table.snapshotManager().latestSnapshotId(); + IcebergMetadata metadata = + IcebergMetadata.fromPath( + fileIO, + new Path( + table.location(), + "metadata/v" + latestSnapshotId + ".metadata.json")); + assertThat(metadata.currentSnapshot().summary().operation()).isEqualTo("replace"); + write.close(); commit.close(); }