diff --git a/paimon-spark/paimon-spark-common/src/main/java/org/apache/paimon/spark/procedure/ExpireSnapshotsProcedure.java b/paimon-spark/paimon-spark-common/src/main/java/org/apache/paimon/spark/procedure/ExpireSnapshotsProcedure.java index 738a5157d9a5..f24f18067a39 100644 --- a/paimon-spark/paimon-spark-common/src/main/java/org/apache/paimon/spark/procedure/ExpireSnapshotsProcedure.java +++ b/paimon-spark/paimon-spark-common/src/main/java/org/apache/paimon/spark/procedure/ExpireSnapshotsProcedure.java @@ -89,20 +89,12 @@ public InternalRow[] call(InternalRow args) { builder.snapshotRetainMin(retainMin); } if (!StringUtils.isNullOrWhitespaceOnly(olderThanStr)) { - long olderThanMills; - // forward compatibility for timestamp type - if (StringUtils.isNumeric(olderThanStr)) { - olderThanMills = Long.parseLong(olderThanStr) / 1000; - builder.snapshotTimeRetain( - Duration.ofMillis(System.currentTimeMillis() - olderThanMills)); - } else { - olderThanMills = - DateTimeUtils.parseTimestampData( - olderThanStr, 3, TimeZone.getDefault()) - .getMillisecond(); - builder.snapshotTimeRetain( - Duration.ofMillis(System.currentTimeMillis() - olderThanMills)); - } + long olderThanMills = + DateTimeUtils.parseTimestampData( + olderThanStr, 3, TimeZone.getDefault()) + .getMillisecond(); + builder.snapshotTimeRetain( + Duration.ofMillis(System.currentTimeMillis() - olderThanMills)); } if (maxDeletes != null) { builder.snapshotMaxDeletes(maxDeletes); diff --git a/paimon-spark/paimon-spark-common/src/test/scala/org/apache/paimon/spark/procedure/ExpireSnapshotsProcedureTest.scala b/paimon-spark/paimon-spark-common/src/test/scala/org/apache/paimon/spark/procedure/ExpireSnapshotsProcedureTest.scala index 18a5ffd6eca3..da7be423108a 100644 --- a/paimon-spark/paimon-spark-common/src/test/scala/org/apache/paimon/spark/procedure/ExpireSnapshotsProcedureTest.scala +++ b/paimon-spark/paimon-spark-common/src/test/scala/org/apache/paimon/spark/procedure/ExpireSnapshotsProcedureTest.scala @@ -141,7 +141,7 @@ class ExpireSnapshotsProcedureTest extends PaimonSparkTestBase with StreamTest { } } - test("test parameter order_than with old timestamp type and new string type") { + test("Paimon Procedure: test parameter order_than with string type") { sql( "CREATE TABLE T (a INT, b STRING) " + "TBLPROPERTIES ( 'num-sorted-run.compaction-trigger' = '999' )") @@ -154,17 +154,10 @@ class ExpireSnapshotsProcedureTest extends PaimonSparkTestBase with StreamTest { } checkSnapshots(snapshotManager, 1, 5) - // older_than with old timestamp type, like "1724664000000" - val nanosecond: Long = snapshotManager.latestSnapshot().timeMillis * 1000 - spark.sql( - s"CALL paimon.sys.expire_snapshots(table => 'test.T', older_than => $nanosecond, max_deletes => 2)") - checkSnapshots(snapshotManager, 3, 5) - - // older_than with new string type, like "2024-08-26 17:20:00" val timestamp = new Timestamp(snapshotManager.latestSnapshot().timeMillis) spark.sql( s"CALL paimon.sys.expire_snapshots(table => 'test.T', older_than => '${timestamp.toString}', max_deletes => 2)") - checkSnapshots(snapshotManager, 5, 5) + checkSnapshots(snapshotManager, 3, 5) } def checkSnapshots(sm: SnapshotManager, earliest: Int, latest: Int): Unit = {