This is an automated email from the ASF dual-hosted git repository.

lzljs3620320 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/paimon.git


The following commit(s) were added to refs/heads/master by this push:
     new 7624b00ce4 [test] Add tests for return empty in testSnapshotMethods
7624b00ce4 is described below

commit 7624b00ce4e66a0af97c7f7e09da3ee4a9f0e5c7
Author: JingsongLi <[email protected]>
AuthorDate: Tue May 27 12:01:09 2025 +0800

    [test] Add tests for return empty in testSnapshotMethods
---
 .../src/test/java/org/apache/paimon/rest/RESTCatalogServer.java   | 8 ++++++--
 .../src/test/java/org/apache/paimon/rest/RESTCatalogTest.java     | 8 ++++++++
 2 files changed, 14 insertions(+), 2 deletions(-)

diff --git 
a/paimon-core/src/test/java/org/apache/paimon/rest/RESTCatalogServer.java 
b/paimon-core/src/test/java/org/apache/paimon/rest/RESTCatalogServer.java
index 3b88e76d90..07e338c10d 100644
--- a/paimon-core/src/test/java/org/apache/paimon/rest/RESTCatalogServer.java
+++ b/paimon-core/src/test/java/org/apache/paimon/rest/RESTCatalogServer.java
@@ -86,6 +86,7 @@ import org.apache.paimon.table.FileStoreTable;
 import org.apache.paimon.table.FileStoreTableFactory;
 import org.apache.paimon.table.Instant;
 import org.apache.paimon.table.TableSnapshot;
+import org.apache.paimon.tag.Tag;
 import org.apache.paimon.utils.BranchManager;
 import org.apache.paimon.utils.Pair;
 import org.apache.paimon.utils.SnapshotManager;
@@ -697,9 +698,12 @@ public class RESTCatalogServer {
             } else {
                 try {
                     long snapshotId = Long.parseLong(version);
-                    snapshot = snapshotManager.snapshot(snapshotId);
+                    snapshot = snapshotManager.tryGetSnapshot(snapshotId);
                 } catch (NumberFormatException e) {
-                    snapshot = 
table.tagManager().get(version).get().trimToSnapshot();
+                    Optional<Tag> tag = table.tagManager().get(version);
+                    if (tag.isPresent()) {
+                        snapshot = tag.get().trimToSnapshot();
+                    }
                 }
             }
         } catch (Exception ignored) {
diff --git 
a/paimon-core/src/test/java/org/apache/paimon/rest/RESTCatalogTest.java 
b/paimon-core/src/test/java/org/apache/paimon/rest/RESTCatalogTest.java
index 9950013486..7e6d8d9401 100644
--- a/paimon-core/src/test/java/org/apache/paimon/rest/RESTCatalogTest.java
+++ b/paimon-core/src/test/java/org/apache/paimon/rest/RESTCatalogTest.java
@@ -1700,6 +1700,10 @@ public abstract class RESTCatalogTest extends 
CatalogTestBase {
                         ""),
                 true);
         Table table = catalog.getTable(identifier);
+
+        assertThat(catalog.loadSnapshot(identifier, "EARLIEST")).isEmpty();
+        assertThat(catalog.loadSnapshot(identifier, "LATEST")).isEmpty();
+
         batchWrite(table, singletonList(1));
         batchWrite(table, singletonList(1));
         batchWrite(table, singletonList(1));
@@ -1719,6 +1723,8 @@ public abstract class RESTCatalogTest extends 
CatalogTestBase {
                 .get()
                 .isEqualTo(table.snapshot(1));
 
+        assertThat(catalog.loadSnapshot(identifier, "8")).isEmpty();
+
         assertThat(catalog.loadSnapshot(identifier, "LATEST"))
                 .isPresent()
                 .get()
@@ -1730,6 +1736,8 @@ public abstract class RESTCatalogTest extends 
CatalogTestBase {
                 .get()
                 .isEqualTo(table.snapshot(2));
 
+        assertThat(catalog.loadSnapshot(identifier, "NONE_TAG")).isEmpty();
+
         assertThat(catalog.loadSnapshot(identifier, "15")).isEmpty();
 
         // test more snapshots

Reply via email to