siddharthteotia commented on code in PR #9100:
URL: https://github.com/apache/pinot/pull/9100#discussion_r937191524


##########
pinot-query-planner/src/main/java/org/apache/pinot/query/planner/logical/StagePlanner.java:
##########
@@ -105,30 +113,128 @@ private StageNode walkRelPlan(RelNode node, int 
currentStageId) {
       RelDistribution.Type exchangeType = distribution.getType();
 
       // 2. make an exchange sender and receiver node pair
-      StageNode mailboxReceiver = new MailboxReceiveNode(currentStageId, 
nextStageRoot.getDataSchema(),
-          nextStageRoot.getStageId(), exchangeType);
-      StageNode mailboxSender = new 
MailboxSendNode(nextStageRoot.getStageId(), nextStageRoot.getDataSchema(),
-          mailboxReceiver.getStageId(), exchangeType, exchangeType == 
RelDistribution.Type.HASH_DISTRIBUTED
-          ? new FieldSelectionKeySelector(distributionKeys) : null);
+      KeySelector<Object[], Object[]> keySelector = exchangeType == 
RelDistribution.Type.HASH_DISTRIBUTED
+          ? new FieldSelectionKeySelector(distributionKeys) : null;
+
+      StageNode mailboxReceiver;
+      StageNode mailboxSender;
+      if (canSkipShuffle(nextStageRoot, keySelector)) {
+        mailboxReceiver = new MailboxReceiveNode(currentStageId, 
nextStageRoot.getDataSchema(),
+            nextStageRoot.getStageId(), RelDistribution.Type.SINGLETON, 
keySelector);
+        mailboxSender = new MailboxSendNode(nextStageRoot.getStageId(), 
nextStageRoot.getDataSchema(),
+            mailboxReceiver.getStageId(), RelDistribution.Type.SINGLETON, 
keySelector);

Review Comment:
   (nit) suggest adding a comment to explain SINGLETON means local otherwise it 
may confuse someone like I thought during our discussion that SINGLETON means 
single RECEIVER (which is what Calcite probably implies) but we are using 
differently



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

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


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

Reply via email to