vlsi commented on a change in pull request #2458:
URL: https://github.com/apache/calcite/pull/2458#discussion_r690577028



##########
File path: 
core/src/main/java/org/apache/calcite/rel/rel2sql/RelToSqlConverter.java
##########
@@ -504,9 +542,18 @@ protected Builder buildAggregate(Aggregate e, Builder 
builder,
           SqlStdOperatorTable.ROLLUP.createCall(SqlParserPos.ZERO, groupKeys));
     default:
     case OTHER:
+      // Make sure that the group sets contains all bits.
+      final List<ImmutableBitSet> groupSets;
+      if (aggregate.getGroupSet()
+          .equals(ImmutableBitSet.union(aggregate.groupSets))) {
+        groupSets = aggregate.getGroupSets();
+      } else {
+        groupSets = new ArrayList<>(aggregate.getGroupSets());
+        groupSets.add(0, aggregate.getGroupSet());

Review comment:
       I've no idea how many group sets would appear here, however, it would 
probably be safer to pre-size the array as `groupSets.size + 1`, then 
`groupSets.add(aggregate.getGroupSet())`, then 
`groupSets.addAll(aggregate.getGroupSets())`.
   
   I guess the difference is not significant, however, it would be safer and it 
would avoid questions during review




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


Reply via email to