xiangfu0 commented on code in PR #18817:
URL: https://github.com/apache/pinot/pull/18817#discussion_r3509655525
##########
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:
Done — switched to match Calcite's bitset behavior in e4529c1: the wire now
carries each grouping set as its member-column-index list (mirroring Calcite's
per-set `ImmutableBitSet`), and the `$groupingId` discriminator is the
grouping-set ordinal instead of a 32-bit mask, so the 31-column limit is gone
in both engines (SSE and MSE). `GROUPING()`/`GROUPING_ID()` values are
precomputed per ordinal from set membership — an O(1) lookup at the SSE reduce
and plan-time constants in the MSE projection — with only the inherent per-call
cap of 31 arguments (packed INT), rejected at parse time. Added 40-column
parser/planner/conversion tests and a 34-union-column RepeatOperator regression
test; the retired wire fields (thrift 14, proto 8) were never released, so the
ids are reserved and this ships in the same release as the feature.
_🤖 Addressed by [Claude Code](https://claude.com/claude-code)_
--
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]