Neer393 commented on code in PR #6039: URL: https://github.com/apache/hive/pull/6039#discussion_r2298338266
########## standalone-metastore/metastore-client/src/main/java/org/apache/hadoop/hive/metastore/utils/TableFetcher.java: ########## @@ -110,24 +112,29 @@ public List<TableName> getTableNames() throws Exception { return candidates; } - public List<Table> getTables(int maxBatchSize) throws Exception { - List<Table> candidates = new ArrayList<>(); - + public Iterable<Table> getTables(int maxBatchSize, Set<String> skipDBs, Set<String> skipTables) throws Exception { // if tableTypes is empty, then a list with single empty string has to specified to scan no tables. if (tableTypes.isEmpty()) { LOG.info("Table fetcher returns empty list as no table types specified"); - return candidates; + return Collections.emptyList(); } - List<String> databases = client.getDatabases(catalogName, dbPattern); - - for (String db : databases) { - List<String> tablesNames = getTableNamesForDatabase(catalogName, db); - for (Table table : new TableIterable(client, db, tablesNames, maxBatchSize)) { - candidates.add(table); - } - } - return candidates; + List<String> databases = client.getDatabases(catalogName, dbPattern).stream() + .filter(dbName -> skipDBs == null || !skipDBs.contains(dbName)).toList(); + + return () -> Iterators.concat( + Iterators.transform(databases.iterator(), db -> { + try { + List<String> tableNames = getTableNamesForDatabase(catalogName, db).stream() + .filter(tableName -> skipTables == null || + !skipTables.contains(TableName.fromString(tableName, catalogName, db).getNotEmptyDbTable())) Review Comment: getQualified adds the catalogname as the prefix but the skiptables set that we have contains tables in the format `dbname.tablename` so ideally we cannot use getQualified ``` public static String getQualified(String catName, String dbName, String tableName) { return catName + DatabaseName.CAT_DB_TABLE_SEPARATOR + dbName + DatabaseName.CAT_DB_TABLE_SEPARATOR + tableName; } ``` ``` public String getNotEmptyDbTable() { String metaRefName = tableMetaRef == null ? "" : "." + tableMetaRef; return db == null || db.trim().isEmpty() ? table : db + DatabaseName.CAT_DB_TABLE_SEPARATOR + table + metaRefName; } ``` -- 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: gitbox-unsubscr...@hive.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: gitbox-unsubscr...@hive.apache.org For additional commands, e-mail: gitbox-h...@hive.apache.org