Copilot commented on code in PR #18662:
URL: https://github.com/apache/pinot/pull/18662#discussion_r3391776375


##########
pinot-core/src/main/java/org/apache/pinot/core/query/request/context/utils/QueryContextConverterUtils.java:
##########
@@ -114,6 +114,34 @@ public static QueryContext getQueryContext(PinotQuery 
pinotQuery) {
       }
     }
 
+    /// GROUP BY GROUPING SETS / ROLLUP / CUBE: the wire carries one 
membership bitmask per set over
+    /// groupByExpressions (the union of all grouping columns). Decode each 
mask into the sorted list of
+    /// participating column indexes; a mask of 0 yields the empty 
(grand-total) set (). Null when this is a
+    /// plain GROUP BY query.
+    List<int[]> groupingSets = null;
+    List<Integer> groupingSetMasks = pinotQuery.getGroupingSetMasks();
+    if (groupingSetMasks != null) {
+      int numGroupByExpressions = groupByExpressions != null ? 
groupByExpressions.size() : 0;
+      groupingSets = new ArrayList<>(groupingSetMasks.size());
+      for (int mask : groupingSetMasks) {

Review Comment:
   When `groupingSetMasks` is present, the code validates individual masks but 
does not validate the size of the GROUP BY union itself. If 
`groupByExpressions.size()` is 32+ (possible via a corrupted/malformed Thrift 
request), the synthetic `$groupingId` bitmask cannot be represented safely (bit 
31 would be the sign bit), and `GroupingSetsGroupKeyGenerator` will compute 
negative grouping-id values, leading to inconsistent behavior. Also, an empty 
`groupingSetMasks` list would currently be treated as “grouping sets enabled” 
but produce no groups (silently empty results). Reject these malformed requests 
during conversion.



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