You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pinot.apache.org by "walterddr (via GitHub)" <gi...@apache.org> on 2023/05/02 03:55:34 UTC

[GitHub] [pinot] walterddr commented on a diff in pull request #10692: 10688: Handling the Join route parsing

walterddr commented on code in PR #10692:
URL: https://github.com/apache/pinot/pull/10692#discussion_r1181734700


##########
pinot-common/src/main/java/org/apache/pinot/sql/parsers/CalciteSqlParser.java:
##########
@@ -199,7 +199,7 @@ public static List<String> extractTableNamesFromNode(SqlNode sqlNode) {
   }
 
   @VisibleForTesting
-  static SqlNodeAndOptions extractSqlNodeAndOptions(String sql, SqlNodeList sqlNodeList) {
+  public static SqlNodeAndOptions extractSqlNodeAndOptions(String sql, SqlNodeList sqlNodeList) {

Review Comment:
   i dont think this is relevant?



##########
pinot-clients/pinot-java-client/src/main/java/org/apache/pinot/client/utils/BrokerSelectorUtils.java:
##########
@@ -0,0 +1,47 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.pinot.client.utils;
+
+import java.util.List;
+import java.util.Objects;
+
+
+public class BrokerSelectorUtils {
+
+  private BrokerSelectorUtils() {
+  }
+
+  /**
+   *
+   * @param tablesBrokersList: List of brokers hosting each table in the list.
+   * @return list of common brokers hosting all the tables.
+   */
+  public static List<String> getTablesCommonBrokers(List<List<String>> tablesBrokersList) {

Review Comment:
   do we plan to move more utils into this class? 



##########
pinot-clients/pinot-java-client/src/main/java/org/apache/pinot/client/BrokerSelector.java:
##########
@@ -23,10 +23,10 @@
 public interface BrokerSelector {
   /**
    * Returns the broker address in the form host:port
-   * @param table
+   * @param tableNames
    * @return
    */
-  String selectBroker(String table);
+  String selectBroker(List<String> tableNames);

Review Comment:
   i would add an interface or change it to var-arg.
   this will create backward compatibility issue for whoever extends this class
   ```suggestion
     String selectBroker(String... tableNames);
   ```



##########
pinot-clients/pinot-java-client/src/main/java/org/apache/pinot/client/Connection.java:
##########
@@ -116,8 +118,8 @@ public ResultSetGroup execute(Request request)
    */
   public ResultSetGroup execute(@Nullable String tableName, String query)
       throws PinotClientException {
-    tableName = tableName == null ? resolveTableName(query) : tableName;
-    String brokerHostPort = _brokerSelector.selectBroker(tableName);
+    List<String> tableNames = (tableName == null) ? resolveTableName(query) : Arrays.asList(tableName);

Review Comment:
   ```suggestion
       List<String> tableNames = (tableName == null) ? resolveTableName(query) : Collections.singletonList(tableName);
   ```



##########
pinot-clients/pinot-java-client/src/main/java/org/apache/pinot/client/DynamicBrokerSelector.java:
##########
@@ -86,24 +87,20 @@ private void refresh() {
 
   @Nullable
   @Override
-  public String selectBroker(String table) {
-    if (table != null) {
-      String tableName =
-          table.replace(ExternalViewReader.OFFLINE_SUFFIX, "").replace(ExternalViewReader.REALTIME_SUFFIX, "");
-      List<String> list = _tableToBrokerListMapRef.get().get(tableName);
-      if (list != null && !list.isEmpty()) {
-        return list.get(RANDOM.nextInt(list.size()));
-      }
-      // In case tableName is formatted as <db>.<table>
-      int idx = tableName.indexOf('.');
-      if (idx > 0) {
-        tableName = tableName.substring(idx + 1);
+  public String selectBroker(List<String> tableNames) {
+    if (tableNames != null) {
+      List<List<String>> commonBrokers = new ArrayList<>();

Review Comment:
   this logic seems similar to the one in brokercache do we plan to put them in utils too later?
   also we don't really need to get the broker list for each table and then add to the commonBroker. we can simply call 1st table, then continuously call retainAll on the remaining table?



-- 
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-unsubscribe@pinot.apache.org

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


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