shounakmk219 commented on code in PR #12417:
URL: https://github.com/apache/pinot/pull/12417#discussion_r1517978582


##########
pinot-controller/src/main/java/org/apache/pinot/controller/helix/core/PinotHelixResourceManager.java:
##########
@@ -709,68 +709,131 @@ public List<String> getAllResources() {
   }
 
   /**
-   * Get all table names (with type suffix).
+   * Get all table names (with type suffix) in default database.
    *
-   * @return List of table names
+   * @return List of table names in default database
    */
   public List<String> getAllTables() {
+    return getAllTables(null);
+  }
+
+  /**
+   * Get all table names (with type suffix) from provided database.
+   *
+   * @param databaseName database name
+   * @return List of table names in provided database name
+   */
+  public List<String> getAllTables(String databaseName) {
     List<String> tableNames = new ArrayList<>();
     for (String resourceName : getAllResources()) {
-      if (TableNameBuilder.isTableResource(resourceName)) {
+      if (TableNameBuilder.isTableResource(resourceName) && 
isPartOfDatabase(resourceName, databaseName)) {
         tableNames.add(resourceName);
       }
     }
     return tableNames;
   }
 
+  private boolean isPartOfDatabase(String tableName, String databaseName) {
+    if (databaseName == null) {
+      return StringUtils.split(tableName, '.').length == 1;
+    } else if 
(databaseName.equalsIgnoreCase(CommonConstants.DEFAULT_DATABASE)) {
+      String[] split = StringUtils.split(tableName, '.');
+      return split.length == 1 || 
split[0].equalsIgnoreCase(CommonConstants.DEFAULT_DATABASE);

Review Comment:
   Agree. The APIs will ensure that constraint going forward. Should we drop 
the ball on existing tables with `default.` prefix?



-- 
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: commits-unsubscr...@pinot.apache.org

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


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

Reply via email to