This is an automated email from the ASF dual-hosted git repository.

xiangfu pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/pinot.git


The following commit(s) were added to refs/heads/master by this push:
     new afb75d25e6 Logical table: quick refactoring and java docs. (#15770)
afb75d25e6 is described below

commit afb75d25e68540ed772a0bbd1ec58be37c95177d
Author: Abhishek Bafna <aba...@startree.ai>
AuthorDate: Tue May 13 11:26:39 2025 +0530

    Logical table: quick refactoring and java docs. (#15770)
    
    Co-authored-by: abhishekbafna <abhishek.ba...@startree.ai>
---
 .../helix/core/PinotHelixResourceManager.java      | 52 +++++++++++++---------
 1 file changed, 30 insertions(+), 22 deletions(-)

diff --git 
a/pinot-controller/src/main/java/org/apache/pinot/controller/helix/core/PinotHelixResourceManager.java
 
b/pinot-controller/src/main/java/org/apache/pinot/controller/helix/core/PinotHelixResourceManager.java
index de7b6bba80..0afdb1fac7 100644
--- 
a/pinot-controller/src/main/java/org/apache/pinot/controller/helix/core/PinotHelixResourceManager.java
+++ 
b/pinot-controller/src/main/java/org/apache/pinot/controller/helix/core/PinotHelixResourceManager.java
@@ -1653,16 +1653,29 @@ public class PinotHelixResourceManager {
     return ZKMetadataProvider.getTableSchema(_propertyStore, tableConfig);
   }
 
+  /**
+   * Get all schema names in the cluster across all databases.
+   * @return List of schema names
+   */
   public List<String> getAllSchemaNames() {
     return _propertyStore.getChildNames(
         
PinotHelixPropertyStoreZnRecordProvider.forSchema(_propertyStore).getRelativePath(),
 AccessOption.PERSISTENT
     );
   }
 
+  /**
+   * Get all schema names in the cluster for default database.
+   * @return List of schema names
+   */
   public List<String> getSchemaNames() {
     return getSchemaNames(null);
   }
 
+  /**
+   * Get all schema names in the cluster for a given database.
+   * @param databaseName Database name to filter schema names
+   * @return List of schema names
+   */
   public List<String> getSchemaNames(@Nullable String databaseName) {
     List<String> schemas = _propertyStore.getChildNames(
         
PinotHelixPropertyStoreZnRecordProvider.forSchema(_propertyStore).getRelativePath(),
 AccessOption.PERSISTENT);
@@ -1841,18 +1854,7 @@ public class PinotHelixResourceManager {
     String tableName = logicalTableConfig.getTableName();
     LOGGER.info("Adding logical table {}: Start", tableName);
 
-    if (StringUtils.isEmpty(logicalTableConfig.getBrokerTenant())) {
-      logicalTableConfig.setBrokerTenant("DefaultTenant");
-    }
-
-    PinotHelixPropertyStoreZnRecordProvider 
pinotHelixPropertyStoreZnRecordProvider =
-        PinotHelixPropertyStoreZnRecordProvider.forTable(_propertyStore);
-    LogicalTableConfigUtils.validateLogicalTableConfig(
-        logicalTableConfig,
-        pinotHelixPropertyStoreZnRecordProvider::exist,
-        getAllBrokerTenantNames()::contains,
-        _propertyStore
-    );
+    validateLogicalTableConfig(logicalTableConfig);
 
     // Check if the logical table name is already used
     if (ZKMetadataProvider.isLogicalTableExists(_propertyStore, tableName)) {
@@ -1860,6 +1862,8 @@ public class PinotHelixResourceManager {
     }
 
     // Check if the table name is already used by a physical table
+    PinotHelixPropertyStoreZnRecordProvider 
pinotHelixPropertyStoreZnRecordProvider =
+        PinotHelixPropertyStoreZnRecordProvider.forTable(_propertyStore);
     if 
(pinotHelixPropertyStoreZnRecordProvider.exist(TableNameBuilder.OFFLINE.tableNameWithType(tableName))
     || 
pinotHelixPropertyStoreZnRecordProvider.exist(TableNameBuilder.REALTIME.tableNameWithType(tableName)))
 {
       throw new TableAlreadyExistsException("Table name: " + tableName + " 
already exists");
@@ -2131,16 +2135,7 @@ public class PinotHelixResourceManager {
     String tableName = logicalTableConfig.getTableName();
     LOGGER.info("Updating logical table {}: Start", tableName);
 
-    if (StringUtils.isEmpty(logicalTableConfig.getBrokerTenant())) {
-      logicalTableConfig.setBrokerTenant("DefaultTenant");
-    }
-
-    LogicalTableConfigUtils.validateLogicalTableConfig(
-        logicalTableConfig,
-        
PinotHelixPropertyStoreZnRecordProvider.forTable(_propertyStore)::exist,
-        getAllBrokerTenantNames()::contains,
-        _propertyStore
-    );
+    validateLogicalTableConfig(logicalTableConfig);
 
     LogicalTableConfig oldLogicalTableConfig = 
ZKMetadataProvider.getLogicalTableConfig(_propertyStore, tableName);
     if (oldLogicalTableConfig == null) {
@@ -2169,6 +2164,19 @@ public class PinotHelixResourceManager {
     });
   }
 
+  private void validateLogicalTableConfig(LogicalTableConfig 
logicalTableConfig) {
+    if (StringUtils.isEmpty(logicalTableConfig.getBrokerTenant())) {
+      logicalTableConfig.setBrokerTenant("DefaultTenant");
+    }
+
+    LogicalTableConfigUtils.validateLogicalTableConfig(
+        logicalTableConfig,
+        
PinotHelixPropertyStoreZnRecordProvider.forTable(_propertyStore)::exist,
+        getAllBrokerTenantNames()::contains,
+        _propertyStore
+    );
+  }
+
   /**
    * Sets the given table config into zookeeper with the expected version, 
which is the previous tableConfig znRecord
    * version. If the expected version is -1, the version check is ignored.


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

Reply via email to