Repository navigation
Fix missing GROUPING SETS in multi-stage EXPLAIN when asking servers - #19769
Merged
Merged
Conversation
1 task
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #19769 +/- ##
=========================================
Coverage 68.40% 68.40%
Complexity 1470 1470
=========================================
Files 3521 3521
Lines 229091 229098 +7
Branches 36346 36348 +2
=========================================
+ Hits 156707 156721 +14
+ Misses 60104 60092 -12
- Partials 12280 12285 +5
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Jackie-Jiang
approved these changes
Oct 6, 2026
yashmayya
force-pushed
the
explain-plan-grouping-sets
branch
from
October 7, 2026 01:38
a21bcb7 to
d050380
Compare
gortiz
approved these changes
Oct 7, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR flow
Fixes missing GROUPING SETS in multi-stage EXPLAIN by updating PlanNodeToRelConverter to handle grouping sets. Supported by F1 changes in visitAggregate method.
AI-generated · Green: added · Yellow: modified · Red: removed · Gray: existing
Diff evidence
This PR depends on #19767, which depends on #19766. It contains their commits. Only the last commit is new.
The bug
With
explainAskingServers(or the broker configpinot.query.multistage.explain.include.segment.plan), the broker gets the plan of each leaf stage from the servers. ThenPlanNodeToRelConverterconverts the plan nodes back to Calcite nodes.visitAggregatebuilds the group key only fromAggregateNode.getGroupKeys()and ignoresgetGroupingSets(). So a GROUPING SETS / ROLLUP / CUBE aggregate that runs as a multi-stage operator in a leaf stage shows as a plain GROUP BY.For example, with
is_partitioned_by_group_by_keys, the ROLLUP aggregate of this query runs in the leaf stage, above the inner aggregate:EXPLAIN PLAN WITHOUT IMPLEMENTATIONshows this aggregate asPinotLogicalAggregate(group=[{0, 1}], groups=[[{0, 1}, {0}, {}]], agg#0=[MAX($2)], aggType=[LEAF]). EXPLAIN with the plan from the servers shows the leaf stage as:The fix
In
visitAggregate, if the node has grouping sets, build the group key withRelBuilder.groupKey(ImmutableBitSet, Iterable<ImmutableBitSet>). Each grouping set holds indexes into the group keys, so the converter maps them to input fields first. Plain GROUP BY does not change.Only the EXPLAIN output changes. Query execution does not use this conversion.
Testing
PlanNodeToRelConverterTest.testAggregateGroupingSetsconverts a ROLLUP aggregate whose group keys are not the first input fields. Without this change, it fails, because the plan has nogroups.pinot-query-plannertests pass.spotless,checkstyleandlicenseare clean.Not in this PR
GroupBy(groupKeys=[[Carrier, Origin]], ...).GroupByOperatordoes not print the grouping sets.UNNESTin a leaf stage shows asUnknownAggregate, with or without grouping sets.visitUnnestkeeps only the unnested columns, so the aggregate cannot find its input fields.