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


##########
extensions-core/multi-stage-query/src/main/java/org/apache/druid/msq/querykit/scan/ScanQueryKit.java:
##########
@@ -132,17 +132,22 @@ public QueryDefinition makeQueryDefinition(
     // Update partition by of next window
     final RowSignature signatureSoFar = signatureBuilder.build();
     boolean addShuffle = true;
-    if 
(originalQuery.getContext().containsKey(MultiStageQueryContext.NEXT_WINDOW_SHUFFLE_COL))
 {
-      final ClusterBy windowClusterBy = (ClusterBy) originalQuery.getContext()
-                                                                 
.get(MultiStageQueryContext.NEXT_WINDOW_SHUFFLE_COL);
-      for (KeyColumn c : windowClusterBy.getColumns()) {
-        if (!signatureSoFar.contains(c.columnName())) {
-          addShuffle = false;
-          break;
+    boolean windowHasEmptyOver = false;
+    if 
(originalQuery.getContext().containsKey(MultiStageQueryContext.NEXT_WINDOW_SHUFFLE_SPEC))
 {
+      if 
(originalQuery.getContext().get(MultiStageQueryContext.NEXT_WINDOW_SHUFFLE_SPEC)
 instanceof MixShuffleSpec) {

Review Comment:
   @adarshsanjeev Not having this check fails a bunch of tests for queries like:
   ```sql
   SELECT col4 , LAG(col4) OVER (ORDER BY col4) LAG_col4
   ```
   
   When `clusterByColumns` is `[]`, it ends up with a 
`MaxCountShuffleSpec{clusterBy=ClusterBy{columns=[], bucketByCount=0}, 
partitions=4, aggregate=false}` instead of `MixShuffleSpec` via the 
`resultShuffleSpecFactory`.
   
   Hence, I had to explicitly set it to MixShuffleSpec in the cases of window 
function queries having empty over clause.
   
   <img width="2183" alt="image" 
src="https://github.com/user-attachments/assets/54414aca-9d49-4c27-bb69-b9cf7a25ca6a";>
   



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