This is an automated email from the ASF dual-hosted git repository.

gianm pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/druid.git


The following commit(s) were added to refs/heads/master by this push:
     new 68168f87654 fix: Use optimized aggregators consistently in MSQ 
GroupBy. (#19445)
68168f87654 is described below

commit 68168f87654d72c373ff146151c10dbed448ec21
Author: Gian Merlino <[email protected]>
AuthorDate: Sun May 10 21:48:17 2026 -0700

    fix: Use optimized aggregators consistently in MSQ GroupBy. (#19445)
    
    Repairs a collision between #19423 and #19397. With cursor-building
    and processing decoupled, both halves of the operation need the
    optimized aggregators.
---
 .../querykit/groupby/GroupByPreShuffleFrameProcessor.java | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)

diff --git 
a/multi-stage-query/src/main/java/org/apache/druid/msq/querykit/groupby/GroupByPreShuffleFrameProcessor.java
 
b/multi-stage-query/src/main/java/org/apache/druid/msq/querykit/groupby/GroupByPreShuffleFrameProcessor.java
index 54f1eda6299..5a7eb2ca6ee 100644
--- 
a/multi-stage-query/src/main/java/org/apache/druid/msq/querykit/groupby/GroupByPreShuffleFrameProcessor.java
+++ 
b/multi-stage-query/src/main/java/org/apache/druid/msq/querykit/groupby/GroupByPreShuffleFrameProcessor.java
@@ -52,6 +52,7 @@ import org.apache.druid.msq.querykit.ReadableInput;
 import org.apache.druid.msq.querykit.SegmentReferenceHolder;
 import org.apache.druid.query.PerSegmentQueryOptimizationContext;
 import org.apache.druid.query.QueryToolChest;
+import org.apache.druid.query.SegmentDescriptor;
 import org.apache.druid.query.aggregation.MetricManipulatorFns;
 import org.apache.druid.query.groupby.GroupByQuery;
 import org.apache.druid.query.groupby.GroupingEngine;
@@ -220,12 +221,9 @@ public class GroupByPreShuffleFrameProcessor extends 
BaseLeafFrameProcessor
         } else {
           currentCursorFactory = 
Objects.requireNonNull(segment.as(CursorFactory.class));
           // Resolve this query using a cursor.
-          final GroupByQuery segmentQuery = (GroupByQuery) query
-              .withQuerySegmentSpec(new 
SpecificSegmentSpec(segmentHolder.getDescriptor()))
-              .optimizeForSegment(new 
PerSegmentQueryOptimizationContext(segmentHolder.getDescriptor()));
           asyncCursorHolder = closer.register(
               groupingEngine.makeCursorHolderAsync(
-                  segmentQuery,
+                  computeQueryForSegment(segmentHolder.getDescriptor()),
                   currentCursorFactory,
                   null
               )
@@ -245,7 +243,7 @@ public class GroupByPreShuffleFrameProcessor extends 
BaseLeafFrameProcessor
         // currentCursorFactory is non-null whenever asyncCursorHolder is 
non-null (both are set together in the
         // first-invocation branch above). The requireNonNull pins the 
invariant for static analysis.
         final Sequence<ResultRow> rowSequence = 
groupingEngine.processCursorHolder(
-            query.withQuerySegmentSpec(new 
SpecificSegmentSpec(segmentHolder.getDescriptor())),
+            computeQueryForSegment(segmentHolder.getDescriptor()),
             Objects.requireNonNull(currentCursorFactory),
             holder,
             currentTimeBoundaryInspector,
@@ -366,4 +364,11 @@ public class GroupByPreShuffleFrameProcessor extends 
BaseLeafFrameProcessor
       tmp.close();
     }
   }
+
+  private GroupByQuery computeQueryForSegment(final SegmentDescriptor 
descriptor)
+  {
+    return (GroupByQuery) query
+        .withQuerySegmentSpec(new SpecificSegmentSpec(descriptor))
+        .optimizeForSegment(new 
PerSegmentQueryOptimizationContext(descriptor));
+  }
 }


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to