Jackie-Jiang commented on code in PR #18817:
URL: https://github.com/apache/pinot/pull/18817#discussion_r3508669020


##########
pinot-query-planner/src/main/java/org/apache/pinot/query/planner/logical/RelToPlanNodeConverter.java:
##########
@@ -706,6 +710,29 @@ private SortNode convertLogicalSort(LogicalSort node) {
         convertInputs(node.getInputs()), 
node.getCollation().getFieldCollations(), fetch, offset);
   }
 
+  /// Encodes each grouping set as a membership bitmask over the union 
group-by columns ({@code groupSet.asList()}),
+  /// mirroring the single-stage engine's {@code PinotQuery.groupingSetMasks} 
so the per-set expansion can be pushed
+  /// down to the single-stage (leaf) engine. Returns an empty list for a 
plain GROUP BY (SIMPLE).
+  public static List<Integer> computeGroupingSetMasks(Aggregate node) {
+    if (node.getGroupType() == Aggregate.Group.SIMPLE) {
+      return List.of();
+    }
+    List<Integer> union = node.getGroupSet().asList();
+    Map<Integer, Integer> unionIndex = new HashMap<>();
+    for (int i = 0; i < union.size(); i++) {
+      unionIndex.put(union.get(i), i);
+    }
+    List<Integer> masks = new ArrayList<>(node.getGroupSets().size());
+    for (ImmutableBitSet set : node.getGroupSets()) {

Review Comment:
   So Calcite stores the mask as a `BitSet` which doesn't have the limit for 
group by columns. Should we do the same for SSE?



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