nastra commented on code in PR #12014:
URL: https://github.com/apache/iceberg/pull/12014#discussion_r1942411767


##########
core/src/main/java/org/apache/iceberg/rest/RESTSessionCatalog.java:
##########
@@ -462,6 +463,26 @@ private LoadTableResponse loadInternal(
 
   @Override
   public Table loadTable(SessionContext context, TableIdentifier identifier) {
+    try {
+      return loadTableInternal(context, identifier);
+    } catch (NoSuchTableException original) {
+      return loadViewMetadataTable(context, identifier);
+    }
+  }
+
+  private Table loadViewMetadataTable(SessionContext context, TableIdentifier 
identifier) {
+    String tableName = identifier.name();
+    ViewMetadataTableType type = ViewMetadataTableType.from(tableName);
+    if (type != null) {
+      TableIdentifier baseViewIdentifier = 
TableIdentifier.of(identifier.namespace().levels());
+      View baseView = loadView(context, baseViewIdentifier);
+      return MetadataTableUtils.createViewMetadataTableInstance(baseView, 
tableName, type);
+    } else {
+      throw new NoSuchTableException("Table does not exist: %s", identifier);

Review Comment:
   we should probably throw the original exception that was caught in 
`loadTable`



-- 
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: issues-unsubscr...@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@iceberg.apache.org
For additional commands, e-mail: issues-h...@iceberg.apache.org

Reply via email to