chunweilei commented on a change in pull request #2241:
URL: https://github.com/apache/calcite/pull/2241#discussion_r517773759
##########
File path: core/src/main/java/org/apache/calcite/plan/SubstitutionVisitor.java
##########
@@ -1930,7 +1930,20 @@ public static MutableRel
unifyAggregates(MutableAggregate query,
}
final List<AggregateCall> aggregateCalls = new ArrayList<>();
for (AggregateCall aggregateCall : query.aggCalls) {
- if (aggregateCall.isDistinct()) {
+ if (aggregateCall.isDistinct() && aggregateCall.getArgList().size() ==
1) {
+ int aggIndex = aggregateCall.getArgList().get(0);
+ if (target.groupSet.asSet().contains(aggIndex)) {
+ int newIndex = target.groupSet.asList().indexOf(aggIndex);
+ aggregateCalls.add(
+ AggregateCall.create(aggregateCall.getAggregation(),
Review comment:
`target.groupSet.asList()` can be replaced by `targetGroupByIndexList`?
[1]https://github.com/apache/calcite/pull/2241/files#diff-61f815e420e8c1c99c7f502f8105d6d2f91724a3bd0cb5ff4300a23ac96f527cR1898
##########
File path: core/src/main/java/org/apache/calcite/plan/SubstitutionVisitor.java
##########
@@ -1930,7 +1930,20 @@ public static MutableRel
unifyAggregates(MutableAggregate query,
}
final List<AggregateCall> aggregateCalls = new ArrayList<>();
for (AggregateCall aggregateCall : query.aggCalls) {
- if (aggregateCall.isDistinct()) {
+ if (aggregateCall.isDistinct() && aggregateCall.getArgList().size() ==
1) {
+ int aggIndex = aggregateCall.getArgList().get(0);
+ if (target.groupSet.asSet().contains(aggIndex)) {
+ int newIndex = target.groupSet.asList().indexOf(aggIndex);
Review comment:
We'd better use a variable to represent `target.groupSet.asSet()` in
case we have to transform it again and again.
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]