diff --git a/paimon-core/src/main/java/org/apache/paimon/table/AbstractFileStoreTable.java b/paimon-core/src/main/java/org/apache/paimon/table/AbstractFileStoreTable.java index 28b215ebc229..af0c3d71ec1c 100644 --- a/paimon-core/src/main/java/org/apache/paimon/table/AbstractFileStoreTable.java +++ b/paimon-core/src/main/java/org/apache/paimon/table/AbstractFileStoreTable.java @@ -577,16 +577,16 @@ public void renameTag(String tagName, String targetTagName) { } @Override - public void replaceTag(String tagName, @Nullable Duration timeRetained) { - Snapshot latestSnapshot = snapshotManager().latestSnapshot(); - SnapshotNotExistException.checkNotNull( - latestSnapshot, "Cannot replace tag because latest snapshot doesn't exist."); - tagManager().replaceTag(latestSnapshot, tagName, timeRetained); - } - - @Override - public void replaceTag(String tagName, long fromSnapshotId, @Nullable Duration timeRetained) { - tagManager().replaceTag(findSnapshot(fromSnapshotId), tagName, timeRetained); + public void replaceTag( + String tagName, @Nullable Long fromSnapshotId, @Nullable Duration timeRetained) { + if (fromSnapshotId == null) { + Snapshot latestSnapshot = snapshotManager().latestSnapshot(); + SnapshotNotExistException.checkNotNull( + latestSnapshot, "Cannot replace tag because latest snapshot doesn't exist."); + tagManager().replaceTag(latestSnapshot, tagName, timeRetained); + } else { + tagManager().replaceTag(findSnapshot(fromSnapshotId), tagName, timeRetained); + } } @Override diff --git a/paimon-core/src/main/java/org/apache/paimon/table/DelegatedFileStoreTable.java b/paimon-core/src/main/java/org/apache/paimon/table/DelegatedFileStoreTable.java index b87292180197..f6f3930baade 100644 --- a/paimon-core/src/main/java/org/apache/paimon/table/DelegatedFileStoreTable.java +++ b/paimon-core/src/main/java/org/apache/paimon/table/DelegatedFileStoreTable.java @@ -188,12 +188,7 @@ public void renameTag(String tagName, String targetTagName) { } @Override - public void replaceTag(String tagName, Duration timeRetained) { - wrapped.replaceTag(tagName, timeRetained); - } - - @Override - public void replaceTag(String tagName, long fromSnapshotId, Duration timeRetained) { + public void replaceTag(String tagName, Long fromSnapshotId, Duration timeRetained) { wrapped.replaceTag(tagName, fromSnapshotId, timeRetained); } diff --git a/paimon-core/src/main/java/org/apache/paimon/table/FormatTable.java b/paimon-core/src/main/java/org/apache/paimon/table/FormatTable.java index 3ae758e73aa2..a53ba545c25e 100644 --- a/paimon-core/src/main/java/org/apache/paimon/table/FormatTable.java +++ b/paimon-core/src/main/java/org/apache/paimon/table/FormatTable.java @@ -272,12 +272,7 @@ default void renameTag(String tagName, String targetTagName) { } @Override - default void replaceTag(String tagName, Duration timeRetained) { - throw new UnsupportedOperationException(); - } - - @Override - default void replaceTag(String tagName, long fromSnapshotId, Duration timeRetained) { + default void replaceTag(String tagName, Long fromSnapshotId, Duration timeRetained) { throw new UnsupportedOperationException(); } diff --git a/paimon-core/src/main/java/org/apache/paimon/table/ReadonlyTable.java b/paimon-core/src/main/java/org/apache/paimon/table/ReadonlyTable.java index 88964ff0f1d5..fe5ebbfcd148 100644 --- a/paimon-core/src/main/java/org/apache/paimon/table/ReadonlyTable.java +++ b/paimon-core/src/main/java/org/apache/paimon/table/ReadonlyTable.java @@ -198,15 +198,7 @@ default void renameTag(String tagName, String targetTagName) { } @Override - default void replaceTag(String tagName, Duration timeRetained) { - throw new UnsupportedOperationException( - String.format( - "Readonly Table %s does not support replaceTag.", - this.getClass().getSimpleName())); - } - - @Override - default void replaceTag(String tagName, long fromSnapshotId, Duration timeRetained) { + default void replaceTag(String tagName, Long fromSnapshotId, Duration timeRetained) { throw new UnsupportedOperationException( String.format( "Readonly Table %s does not support replaceTag.", diff --git a/paimon-core/src/main/java/org/apache/paimon/table/Table.java b/paimon-core/src/main/java/org/apache/paimon/table/Table.java index beb42c849abb..86189b272236 100644 --- a/paimon-core/src/main/java/org/apache/paimon/table/Table.java +++ b/paimon-core/src/main/java/org/apache/paimon/table/Table.java @@ -120,13 +120,9 @@ default String fullName() { @Experimental void renameTag(String tagName, String targetTagName); - /** Replace a tag with new time retained. */ - @Experimental - void replaceTag(String tagName, Duration timeRetained); - /** Replace a tag with new snapshot id and new time retained. */ @Experimental - void replaceTag(String tagName, long fromSnapshotId, Duration timeRetained); + void replaceTag(String tagName, Long fromSnapshotId, Duration timeRetained); /** Delete a tag by name. */ @Experimental diff --git a/paimon-flink/paimon-flink-1.18/src/main/java/org/apache/paimon/flink/procedure/ReplaceTagProcedure.java b/paimon-flink/paimon-flink-1.18/src/main/java/org/apache/paimon/flink/procedure/ReplaceTagProcedure.java index beda4f879205..6ed6ecc0e512 100644 --- a/paimon-flink/paimon-flink-1.18/src/main/java/org/apache/paimon/flink/procedure/ReplaceTagProcedure.java +++ b/paimon-flink/paimon-flink-1.18/src/main/java/org/apache/paimon/flink/procedure/ReplaceTagProcedure.java @@ -29,11 +29,7 @@ public class ReplaceTagProcedure extends CreateOrReplaceTagBaseProcedure { @Override void createOrReplaceTag(Table table, String tagName, Long snapshotId, Duration timeRetained) { - if (snapshotId == null) { - table.replaceTag(tagName, timeRetained); - } else { - table.replaceTag(tagName, snapshotId, timeRetained); - } + table.replaceTag(tagName, snapshotId, timeRetained); } @Override diff --git a/paimon-flink/paimon-flink-common/src/main/java/org/apache/paimon/flink/action/ReplaceTagAction.java b/paimon-flink/paimon-flink-common/src/main/java/org/apache/paimon/flink/action/ReplaceTagAction.java index 025c7b55c256..09a85fe8a25a 100644 --- a/paimon-flink/paimon-flink-common/src/main/java/org/apache/paimon/flink/action/ReplaceTagAction.java +++ b/paimon-flink/paimon-flink-common/src/main/java/org/apache/paimon/flink/action/ReplaceTagAction.java @@ -46,10 +46,6 @@ public ReplaceTagAction( @Override public void run() throws Exception { - if (snapshotId == null) { - table.replaceTag(tagName, timeRetained); - } else { - table.replaceTag(tagName, snapshotId, timeRetained); - } + table.replaceTag(tagName, snapshotId, timeRetained); } } diff --git a/paimon-flink/paimon-flink-common/src/main/java/org/apache/paimon/flink/procedure/ReplaceTagProcedure.java b/paimon-flink/paimon-flink-common/src/main/java/org/apache/paimon/flink/procedure/ReplaceTagProcedure.java index beda4f879205..6ed6ecc0e512 100644 --- a/paimon-flink/paimon-flink-common/src/main/java/org/apache/paimon/flink/procedure/ReplaceTagProcedure.java +++ b/paimon-flink/paimon-flink-common/src/main/java/org/apache/paimon/flink/procedure/ReplaceTagProcedure.java @@ -29,11 +29,7 @@ public class ReplaceTagProcedure extends CreateOrReplaceTagBaseProcedure { @Override void createOrReplaceTag(Table table, String tagName, Long snapshotId, Duration timeRetained) { - if (snapshotId == null) { - table.replaceTag(tagName, timeRetained); - } else { - table.replaceTag(tagName, snapshotId, timeRetained); - } + table.replaceTag(tagName, snapshotId, timeRetained); } @Override diff --git a/paimon-spark/paimon-spark-common/src/main/java/org/apache/paimon/spark/procedure/ReplaceTagProcedure.java b/paimon-spark/paimon-spark-common/src/main/java/org/apache/paimon/spark/procedure/ReplaceTagProcedure.java index 3c33f8fb2ac0..205fca5ee69e 100644 --- a/paimon-spark/paimon-spark-common/src/main/java/org/apache/paimon/spark/procedure/ReplaceTagProcedure.java +++ b/paimon-spark/paimon-spark-common/src/main/java/org/apache/paimon/spark/procedure/ReplaceTagProcedure.java @@ -33,11 +33,7 @@ private ReplaceTagProcedure(TableCatalog tableCatalog) { @Override void createOrReplaceTag(Table table, String tagName, Long snapshotId, Duration timeRetained) { - if (snapshotId == null) { - table.replaceTag(tagName, timeRetained); - } else { - table.replaceTag(tagName, snapshotId, timeRetained); - } + table.replaceTag(tagName, snapshotId, timeRetained); } public static ProcedureBuilder builder() {