abhishekbafna commented on code in PR #17868:
URL: https://github.com/apache/pinot/pull/17868#discussion_r2941497292


##########
pinot-core/src/main/java/org/apache/pinot/core/query/executor/LogicalTableExecutionInfo.java:
##########
@@ -79,19 +82,71 @@ public boolean hasRealtime() {
         .anyMatch(tableExecutionInfo -> 
tableExecutionInfo.getTableDataManager() instanceof RealtimeTableDataManager);
   }
 
+  /**
+   * Returns selected segments and contexts for the logical table. Unlike 
single-table execution, this collects
+   * all segments from every physical table, runs segment pruning once on the 
combined list (cross-table prune),
+   * then resolves segment contexts per table. This allows pruners such as 
SelectionQuerySegmentPruner (ORDER BY +
+   * LIMIT) to prune effectively across the logical table rather than per 
physical table.
+   */
   @Override
   public SelectedSegmentsInfo getSelectedSegmentsInfo(QueryContext 
queryContext, TimerContext timerContext,
       ExecutorService executorService, SegmentPrunerService 
segmentPrunerService) {
-    SelectedSegmentsInfo aggregatedSelectedSegmentsInfo = new 
SelectedSegmentsInfo();
-
+    // Collect all segments from all physical tables (no pruning yet)
+    List<IndexSegment> allSegments = new ArrayList<>();
+    Map<IndexSegment, SingleTableExecutionInfo> segmentToTable = new 
HashMap<>();
+    long numTotalDocs = 0;
     for (SingleTableExecutionInfo tableExecutionInfo : _tableExecutionInfos) {
-      SelectedSegmentsInfo selectedSegmentsInfo =
-          tableExecutionInfo.getSelectedSegmentsInfo(queryContext, 
timerContext, executorService, segmentPrunerService);
-      aggregatedSelectedSegmentsInfo.aggregate(selectedSegmentsInfo);
+      List<IndexSegment> indexSegments = tableExecutionInfo.getIndexSegments();
+      for (IndexSegment segment : indexSegments) {
+        allSegments.add(segment);
+        segmentToTable.put(segment, tableExecutionInfo);
+        numTotalDocs += segment.getSegmentMetadata().getTotalDocs();
+      }
+    }
+    int numTotalSegments = allSegments.size();
+
+    // Constant false shortcut: skip pruning
+    List<IndexSegment> selectedSegments;

Review Comment:
   I think, we should leave that.
   
   The `selectSegments()` is currently a private method, to make accessible we 
would need to make it static and public/default access modifier. This seems 
more hack than code refactoring. We do not access to the 
SingleTableExecutionInfo object and may have to create it.



-- 
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