vrajat commented on code in PR #15773:
URL: https://github.com/apache/pinot/pull/15773#discussion_r2113943032


##########
pinot-query-runtime/src/main/java/org/apache/pinot/query/runtime/plan/server/ServerPlanRequestUtils.java:
##########
@@ -386,4 +409,69 @@ private static List<Expression> 
computeInOperands(List<Object[]> dataContainer,
     }
     return expressions;
   }
+
+  private static List<InstanceRequest> 
constructLogicalTableServerQueryRequests(
+      OpChainExecutionContext executionContext, PinotQuery pinotQuery, 
InstanceDataManager instanceDataManager) {
+    StageMetadata stageMetadata = executionContext.getStageMetadata();
+    String logicalTableName = stageMetadata.getTableName();
+    LogicalTableContext logicalTableContext = 
instanceDataManager.getLogicalTableContext(logicalTableName);
+    Preconditions.checkNotNull(logicalTableContext,
+        "LogicalTableManager not found for logical table name: " + 
logicalTableName);
+
+    Map<String, List<String>> logicalTableSegmentsMap =
+        executionContext.getWorkerMetadata().getLogicalTableSegmentsMap();
+    List<TableSegmentsInfo> offlineTableRouteInfoList = new ArrayList<>();
+    List<TableSegmentsInfo> realtimeTableRouteInfoList = new ArrayList<>();
+
+    Preconditions.checkNotNull(logicalTableSegmentsMap);
+    for (Map.Entry<String, List<String>> entry: 
logicalTableSegmentsMap.entrySet()) {
+      String physicalTableName = entry.getKey();
+      TableType tableType = 
TableNameBuilder.getTableTypeFromTableName(physicalTableName);
+      TableSegmentsInfo tableSegmentsInfo = new TableSegmentsInfo();
+      tableSegmentsInfo.setTableName(physicalTableName);
+      tableSegmentsInfo.setSegments(entry.getValue());
+      if (tableType == TableType.REALTIME) {
+        realtimeTableRouteInfoList.add(tableSegmentsInfo);
+      } else {
+        offlineTableRouteInfoList.add(tableSegmentsInfo);
+      }
+    }
+
+    TimeBoundaryInfo timeBoundaryInfo = stageMetadata.getTimeBoundary();
+
+    if (offlineTableRouteInfoList.isEmpty() || 
realtimeTableRouteInfoList.isEmpty()) {
+      List<TableSegmentsInfo> routeInfoList =
+          offlineTableRouteInfoList.isEmpty() ? realtimeTableRouteInfoList : 
offlineTableRouteInfoList;
+      String tableType = offlineTableRouteInfoList.isEmpty() ? 
TableType.REALTIME.name() : TableType.OFFLINE.name();
+      if (tableType.equals(TableType.OFFLINE.name())) {
+        
Preconditions.checkNotNull(logicalTableContext.getRefOfflineTableConfig());
+        String offlineTableName = 
TableNameBuilder.forType(TableType.OFFLINE).tableNameWithType(logicalTableName);

Review Comment:
   There cant be one broker request per table in the list of `TableSegmentInfo` 
because too many objects will be created. If that wasnt a constraint, then the 
broker request would point to a OFFLINE or REALTIME table each. I kept the same 
semantics that an offline or realtime broker request will at least point to the 
expected table type. OTOH I looked and could not find code that used the table 
name from the broker request. 



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

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