Akshat-Jain commented on code in PR #17038:
URL: https://github.com/apache/druid/pull/17038#discussion_r1774555904


##########
extensions-core/multi-stage-query/src/main/java/org/apache/druid/msq/querykit/WindowOperatorQueryKit.java:
##########
@@ -377,4 +324,37 @@ private static RowSignature 
computeSignatureForFinalWindowStage(RowSignature row
         finalWindowClusterBy.getColumns()
     );
   }
+
+  /**
+   * This method converts the operator chain received from native plan into 
MSQ plan.
+   * (NaiveSortOperator -> Naive/GlueingPartitioningOperator -> 
WindowOperator) is converted into (GlueingPartitioningOperator -> 
PartitionSortOperator -> WindowOperator).
+   * We rely on MSQ's shuffling to do the clustering on partitioning keys for 
us at every stage.
+   * This conversion allows us to blindly read N rows from input channel and 
push them into the operator chain, and repeat until the input channel isn't 
finished.
+   * @param operatorFactoryListFromQuery
+   * @param maxRowsMaterializedInWindow
+   * @return
+   */
+  private List<OperatorFactory> 
getOperatorFactoryListForStageDefinition(List<OperatorFactory> 
operatorFactoryListFromQuery, int maxRowsMaterializedInWindow)
+  {
+    final List<OperatorFactory> operatorFactoryList = new ArrayList<>();
+    final List<OperatorFactory> sortOperatorFactoryList = new ArrayList<>();
+    for (OperatorFactory operatorFactory : operatorFactoryListFromQuery) {
+      if (operatorFactory instanceof BasePartitioningOperatorFactory) {
+        BasePartitioningOperatorFactory partition = 
(BasePartitioningOperatorFactory) operatorFactory;
+        operatorFactoryList.add(new 
GlueingPartitioningOperatorFactory(partition.getPartitionColumns(), 
maxRowsMaterializedInWindow));
+      } else if (operatorFactory instanceof BaseSortOperatorFactory) {
+        BaseSortOperatorFactory sortOperatorFactory = 
(BaseSortOperatorFactory) operatorFactory;
+        sortOperatorFactoryList.add(new 
PartitionSortOperatorFactory(sortOperatorFactory.getSortColumns()));

Review Comment:
   As discussed offline, the translation should be done in the 
`WindowOperatorQueryKit` itself.
   
   Another reason for it is that the `WindowOperatorQueryKit` has access to 
`maxRowsMaterialized` which is needed for creating the 
`GlueingPartitioningOperator`, as discussed in this earlier review comment: 
https://github.com/apache/druid/pull/17038#discussion_r1761136917



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