Jackie-Jiang commented on a change in pull request #5707:
URL: https://github.com/apache/incubator-pinot/pull/5707#discussion_r455398354



##########
File path: 
pinot-broker/src/main/java/org/apache/pinot/broker/requesthandler/BaseBrokerRequestHandler.java
##########
@@ -438,6 +439,46 @@ public BrokerResponse handleRequest(JsonNode request, 
@Nullable RequesterIdentit
     return brokerResponse;
   }
 
+  /**
+   * Check if table is in the format of [database_name].[table_name].
+   *
+   * Only update TableName in QuerySource if there is no existing table in the 
format of [database_name].[table_name],
+   * but only [table_name].
+   *
+   * @param brokerRequest
+   */
+  private void updateQuerySource(BrokerRequest brokerRequest) {
+    String tableName = brokerRequest.getQuerySource().getTableName();
+    // Check if table is in the format of [database_name].[table_name]
+    String[] querySourceSplits = tableName.split("\\.", 2);

Review comment:
       Avoid regex match
   ```suggestion
       String[] tableNameSplits = StringUtils.split(tableName, '.');
   ```

##########
File path: 
pinot-common/src/main/java/org/apache/pinot/common/utils/helix/TableCache.java
##########
@@ -67,6 +67,10 @@ public String getActualTableName(String tableName) {
     return 
_tableConfigChangeListener._tableNameMap.getOrDefault(tableName.toLowerCase(), 
tableName);
   }
 
+  public boolean existTableName(String tableName) {

Review comment:
       Suggest renaming to `containsTable()`

##########
File path: 
pinot-broker/src/main/java/org/apache/pinot/broker/requesthandler/BaseBrokerRequestHandler.java
##########
@@ -438,6 +439,46 @@ public BrokerResponse handleRequest(JsonNode request, 
@Nullable RequesterIdentit
     return brokerResponse;
   }
 
+  /**
+   * Check if table is in the format of [database_name].[table_name].
+   *
+   * Only update TableName in QuerySource if there is no existing table in the 
format of [database_name].[table_name],
+   * but only [table_name].
+   *
+   * @param brokerRequest
+   */
+  private void updateQuerySource(BrokerRequest brokerRequest) {
+    String tableName = brokerRequest.getQuerySource().getTableName();
+    // Check if table is in the format of [database_name].[table_name]
+    String[] querySourceSplits = tableName.split("\\.", 2);
+    if (querySourceSplits.length != 2) {
+      return;
+    }
+    // Update table name if there is no existing table in the format of 
[database_name].[table_name] but only [table_name]
+    if (_enableCaseInsensitive && 
_tableCache.existTableName(querySourceSplits[1]) && !_tableCache
+        .existTableName(tableName)) {
+      // Use TableCache to check case insensitive table name.
+      brokerRequest.getQuerySource().setTableName(querySourceSplits[1]);
+      return;
+    }

Review comment:
       Use 2 if checks to prevent using RoutingManager for case insensitive 
table
   ```suggestion
       if (_enableCaseInsensitive) {
         // Use TableCache to check case insensitive table name.
         if (_tableCache.existTableName(querySourceSplits[1]) && 
!_tableCache.existTableName(tableName)) {
           brokerRequest.getQuerySource().setTableName(querySourceSplits[1]);
         }
         return;
       }
   ```

##########
File path: 
pinot-broker/src/main/java/org/apache/pinot/broker/requesthandler/BaseBrokerRequestHandler.java
##########
@@ -438,6 +439,46 @@ public BrokerResponse handleRequest(JsonNode request, 
@Nullable RequesterIdentit
     return brokerResponse;
   }
 
+  /**
+   * Check if table is in the format of [database_name].[table_name].
+   *
+   * Only update TableName in QuerySource if there is no existing table in the 
format of [database_name].[table_name],
+   * but only [table_name].
+   *
+   * @param brokerRequest
+   */
+  private void updateQuerySource(BrokerRequest brokerRequest) {
+    String tableName = brokerRequest.getQuerySource().getTableName();
+    // Check if table is in the format of [database_name].[table_name]
+    String[] querySourceSplits = tableName.split("\\.", 2);
+    if (querySourceSplits.length != 2) {
+      return;
+    }
+    // Update table name if there is no existing table in the format of 
[database_name].[table_name] but only [table_name]
+    if (_enableCaseInsensitive && 
_tableCache.existTableName(querySourceSplits[1]) && !_tableCache
+        .existTableName(tableName)) {
+      // Use TableCache to check case insensitive table name.
+      brokerRequest.getQuerySource().setTableName(querySourceSplits[1]);
+      return;
+    }
+    // Use RoutingManager to check case sensitive table name.
+    TableType tableType = 
TableNameBuilder.getTableTypeFromTableName(tableName);
+    if (tableType != null && 
_routingManager.routingExists(querySourceSplits[1]) && !_routingManager
+        .routingExists(tableName)) {
+      brokerRequest.getQuerySource().setTableName(querySourceSplits[1]);
+      return;
+    }

Review comment:
       Similarly here
   ```suggestion
       if (TableNameBuilder.isTableResource(tableName)) {
         if (_routingManager.routingExists(querySourceSplits[1]) && 
!_routingManager.routingExists(tableName)) {
           brokerRequest.getQuerySource().setTableName(querySourceSplits[1]);
         }
         return;
       }
   ```




----------------------------------------------------------------
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:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to