docete commented on a change in pull request #11869:
URL: https://github.com/apache/flink/pull/11869#discussion_r414408162



##########
File path: 
flink-table/flink-table-api-java/src/main/java/org/apache/flink/table/catalog/CatalogManager.java
##########
@@ -415,6 +415,37 @@ public CatalogBaseTable getTable() {
                        });
        }
 
+       /**
+        * Returns an array of names of all views(both temporary and permanent) 
registered in
+        * the namespace of the current catalog and database.
+        *
+        * @return names of all registered views
+        */
+       public Set<String> listViews() {
+               return listViews(getCurrentCatalog(), getCurrentDatabase());
+       }
+
+       /**
+        * Returns an array of names of all views(both temporary and permanent) 
registered in
+        * the namespace of the current catalog and database.
+        *
+        * @return names of registered views
+        */
+       public Set<String> listViews(String catalogName, String databaseName) {
+               Catalog currentCatalog = catalogs.get(getCurrentCatalog());
+
+               try {
+                       return Stream.concat(
+                               
currentCatalog.listViews(getCurrentDatabase()).stream(),
+                               listTemporaryTablesInternal(catalogName, 
databaseName)
+                                       .filter(e -> e.getValue() instanceof 
CatalogView)
+                                       .map(e -> e.getKey().getObjectName())
+                       ).collect(Collectors.toSet());

Review comment:
       IMO the private `listTemporaryTablesInternal` is enough. or we should 
add `listTemporaryTables(String catalogName, String databaseName)` for 
`listTemporaryTables()`. That's  probably a bit superfluous.




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

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


Reply via email to