mihaibudiu commented on code in PR #4983:
URL: https://github.com/apache/calcite/pull/4983#discussion_r3357902968
##########
core/src/main/java/org/apache/calcite/rel/rules/AggregateExpandDistinctAggregatesRule.java:
##########
@@ -864,6 +920,23 @@ private static int remap(ImmutableBitSet groupSet, int
arg) {
return arg < 0 ? -1 : groupSet.indexOf(arg);
}
+ private static RelCollation remapCollationForGroupingSets(RelCollation
collation,
+ ImmutableBitSet fullGroupSet) {
+ if (collation.equals(RelCollations.EMPTY)) {
+ return RelCollations.EMPTY;
+ }
+ // Remap each field index through the fullGroupSet
+ final List<RelFieldCollation> remappedFCs = new ArrayList<>();
+ for (RelFieldCollation fc : collation.getFieldCollations()) {
+ int originalIdx = fc.getFieldIndex();
+ int newIdx = fullGroupSet.indexOf(originalIdx);
+ if (newIdx >= 0) {
+ remappedFCs.add(fc.withFieldIndex(newIdx));
Review Comment:
can you explain why is it ok for the result collation to have fewer elements
than the input collation?
--
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]