nk1506 commented on code in PR #9852:
URL: https://github.com/apache/iceberg/pull/9852#discussion_r1578904316


##########
hive-metastore/src/main/java/org/apache/iceberg/hive/HiveCatalog.java:
##########
@@ -152,6 +173,38 @@ public List<TableIdentifier> listTables(Namespace 
namespace) {
     }
   }
 
+  @Override
+  public List<TableIdentifier> listViews(Namespace namespace) {
+    Preconditions.checkArgument(
+        isValidateNamespace(namespace), "Missing database in namespace: %s", 
namespace);
+
+    try {
+      String database = namespace.level(0);
+      List<String> tableNames =
+          clients.run(client -> client.getTables(database, "*", 
TableType.VIRTUAL_VIEW));
+
+      // Retrieving the Table objects from HMS in batches to avoid OOM
+      List<TableIdentifier> filteredTableIdentifiers = Lists.newArrayList();
+      Iterable<List<String>> tableNameSets = Iterables.partition(tableNames, 
100);

Review Comment:
   In case of `listTables()` depends upon the flag `listAllTables` it is either 
returning all the tables name(including `views`) or only iceberg tables.  
   For `listViews()` I don't see need of loading all the table names and then 
filter only iceberg views. 
   To not overuse memory I am using `client.getTables(database, "*", 
TableType.VIRTUAL_VIEW)` instead of `client.getAllTables(database)` .
   
   To fetch required icebergTable/icebergView object either we can share all 
the name list or share it in batch. 
   this approach `Iterable<List<String>> tableNameSets = 
Iterables.partition(tableNames, 100);` was used to avoid any possible OOM 
issues. 
   IMO, the same should be used with `listTables()` too. 



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