stevenzwu commented on code in PR #15831:
URL: https://github.com/apache/iceberg/pull/15831#discussion_r3029469066


##########
core/src/main/java/org/apache/iceberg/rest/CatalogHandlers.java:
##########
@@ -738,6 +744,64 @@ public static LoadViewResponse loadView(ViewCatalog 
catalog, TableIdentifier vie
     return viewResponse(view);
   }
 
+  public static LoadRelationResponse loadRelation(
+      Catalog catalog, ViewCatalog viewCatalog, TableIdentifier ident, 
SnapshotMode mode) {
+    try {
+      LoadTableResponse tableResponse = loadTable(catalog, ident, mode);
+      return 
LoadRelationResponse.builder().withTableResponse(tableResponse).build();
+    } catch (NoSuchTableException e) {
+      if (viewCatalog != null) {
+        try {
+          LoadViewResponse viewResponse = loadView(viewCatalog, ident);
+          return 
LoadRelationResponse.builder().withViewResponse(viewResponse).build();
+        } catch (NoSuchViewException ignored) {
+          // fall through to throw not-found
+        }
+      }
+    }
+
+    throw new NoSuchTableException("No table or view exists for identifier: 
%s", ident);
+  }
+
+  public static BatchLoadRelationsResponse batchLoadRelations(
+      Catalog catalog, ViewCatalog viewCatalog, BatchLoadRelationsRequest 
request) {
+    BatchLoadRelationsResponse.Builder responseBuilder = 
BatchLoadRelationsResponse.builder();
+
+    for (BatchLoadRelationRequestItem item : request.identifiers()) {
+      TableIdentifier ident = item.identifier();
+      SnapshotMode mode = snapshotModeFromString(item.snapshots());
+
+      try {
+        LoadRelationResponse result = loadRelation(catalog, viewCatalog, 
ident, mode);
+        BatchLoadRelationResultItem.Builder itemBuilder =
+            BatchLoadRelationResultItem.builder()
+                .withIdentifier(ident)
+                .withStatus(200)
+                .withResult(result);
+
+        if (result.objectType() == CatalogObjectType.TABLE
+            && result.tableResponse().metadataLocation() != null) {
+          itemBuilder.withEtag(result.tableResponse().metadataLocation());
+        }
+
+        responseBuilder.addResult(itemBuilder.build());
+      } catch (NoSuchTableException | NoSuchViewException e) {
+        responseBuilder.addResult(
+            
BatchLoadRelationResultItem.builder().withIdentifier(ident).withStatus(404).build());

Review Comment:
   there is a related discussion in the spec side that we need to settle first.
   https://github.com/apache/iceberg/pull/15830#discussion_r3022780246



-- 
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]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to