diqiu50 commented on code in PR #11189:
URL: https://github.com/apache/gravitino/pull/11189#discussion_r3298374634


##########
flink-connector/flink-common/src/main/java/org/apache/gravitino/flink/connector/catalog/BaseCatalog.java:
##########
@@ -210,32 +224,66 @@ public List<String> listTables(String databaseName)
   @Override
   public List<String> listViews(String databaseName)
       throws DatabaseNotExistException, CatalogException {
-    // Gravitino does not support views yet; return empty to keep Flink 
callers happy.
-    return Collections.emptyList();
+    try {
+      ViewCatalog viewCatalog = catalog().asViewCatalog();
+      return Arrays.stream(viewCatalog.listViews(Namespace.of(databaseName)))
+          .map(NameIdentifier::name)
+          .collect(Collectors.toList());
+    } catch (UnsupportedOperationException e) {
+      LOG.debug("Catalog {} does not support views; returning empty view 
list", catalogName(), e);
+      return Collections.emptyList();
+    } catch (NoSuchSchemaException e) {
+      throw new DatabaseNotExistException(catalogName(), databaseName, e);
+    } catch (Exception e) {
+      throw new CatalogException(e);
+    }
   }
 
   @Override
   public CatalogBaseTable getTable(ObjectPath tablePath)
       throws TableNotExistException, CatalogException {
+    NameIdentifier ident =
+        NameIdentifier.of(tablePath.getDatabaseName(), 
tablePath.getObjectName());
     try {
-      Table table =
-          catalog()
-              .asTableCatalog()
-              .loadTable(NameIdentifier.of(tablePath.getDatabaseName(), 
tablePath.getObjectName()));
+      Table table = catalog().asTableCatalog().loadTable(ident);
       return toFlinkTable(table, tablePath);
     } catch (NoSuchTableException e) {
-      throw new TableNotExistException(catalogName(), tablePath, e);
+      // Fall through to check views.
     } catch (Exception e) {
+      LOG.warn("Failed to load table {} from catalog {}", ident, 
catalogName(), e);
       throw new CatalogException(e);
     }
+
+    return loadViewOrThrow(tablePath);
   }
 
   @Override
   public boolean tableExists(ObjectPath tablePath) throws CatalogException {
+    NameIdentifier ident =
+        NameIdentifier.of(tablePath.getDatabaseName(), 
tablePath.getObjectName());
     try {
-      return catalog()
-          .asTableCatalog()
-          .tableExists(NameIdentifier.of(tablePath.getDatabaseName(), 
tablePath.getObjectName()));
+      if (catalog().asTableCatalog().tableExists(ident)) {
+        return true;
+      }
+    } catch (Exception e) {
+      throw new CatalogException(e);
+    }
+    try {
+      return catalog().asViewCatalog().viewExists(ident);

Review Comment:
   Not here。 we can check that in load view



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