luoyuxia commented on code in PR #2326:
URL: https://github.com/apache/fluss/pull/2326#discussion_r2785389503


##########
fluss-server/src/main/java/org/apache/fluss/server/RpcServiceBase.java:
##########
@@ -451,31 +444,48 @@ public CompletableFuture<ListPartitionInfosResponse> 
listPartitionInfos(
     }
 
     @Override
-    public CompletableFuture<GetLatestLakeSnapshotResponse> 
getLatestLakeSnapshot(
-            GetLatestLakeSnapshotRequest request) {
+    public CompletableFuture<GetLakeSnapshotResponse> getLakeSnapshot(
+            GetLakeSnapshotRequest request) {
+        // get table info
         TablePath tablePath = toTablePath(request.getTablePath());
         authorizeTable(OperationType.DESCRIBE, tablePath);
 
         // get table info
         TableInfo tableInfo = metadataManager.getTable(tablePath);
         // get table id
         long tableId = tableInfo.getTableId();
-        CompletableFuture<GetLatestLakeSnapshotResponse> resultFuture = new 
CompletableFuture<>();
+        CompletableFuture<GetLakeSnapshotResponse> resultFuture = new 
CompletableFuture<>();
+        boolean readableSnapshot = request.hasReadable() && 
request.isReadable();
         ioExecutor.execute(
                 () -> {
-                    Optional<LakeTableSnapshot> optLakeTableSnapshot;
                     try {
-                        optLakeTableSnapshot = 
zkClient.getLakeTableSnapshot(tableId);
-                        if (!optLakeTableSnapshot.isPresent()) {
-                            resultFuture.completeExceptionally(
-                                    new LakeTableSnapshotNotExistException(
-                                            String.format(
-                                                    "Lake table snapshot not 
exist for table: %s, table id: %d",
-                                                    tablePath, tableId)));
-                        } else {
-                            LakeTableSnapshot lakeTableSnapshot = 
optLakeTableSnapshot.get();
+                        Optional<LakeTableSnapshot> optSnapshot =
+                                readableSnapshot
+                                        ? 
zkClient.getLatestReadableLakeTableSnapshot(tableId)
+                                        : zkClient.getLakeTableSnapshot(
+                                                tableId,
+                                                request.hasSnapshotId()
+                                                        ? 
request.getSnapshotId()
+                                                        : null);

Review Comment:
   good suggestion



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to