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



##########
File path: 
pinot-broker/src/main/java/org/apache/pinot/broker/requesthandler/BaseBrokerRequestHandler.java
##########
@@ -438,6 +439,47 @@ 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[] tableNameSplits = StringUtils.split(tableName, '.');
+    if (tableNameSplits.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) {
+      if (_tableCache.containsTable(tableNameSplits[1]) && 
!_tableCache.containsTable(tableName)) {
+        // Use TableCache to check case insensitive table name.
+        brokerRequest.getQuerySource().setTableName(tableNameSplits[1]);
+      }
+      return;
+    }
+    // Use RoutingManager to check case sensitive table name.
+    if (TableNameBuilder.isTableResource(tableName)) {
+      if (_routingManager.routingExists(tableNameSplits[1]) && 
!_routingManager.routingExists(tableName)) {
+        brokerRequest.getQuerySource().setTableName(tableNameSplits[1]);
+        return;
+      }

Review comment:
       Move `return` outside
   ```suggestion
         if (_routingManager.routingExists(tableNameSplits[1]) && 
!_routingManager.routingExists(tableName)) {
           brokerRequest.getQuerySource().setTableName(tableNameSplits[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