You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@calcite.apache.org by GitBox <gi...@apache.org> on 2021/10/13 08:46:31 UTC

[GitHub] [calcite] asolimando commented on a change in pull request #2522: [CALCITE-4735] Enhance Aggregate-Materialization, when aggcall of query could be expressed by target's grouping (xurenhe)

asolimando commented on a change in pull request #2522:
URL: https://github.com/apache/calcite/pull/2522#discussion_r727838498



##########
File path: core/src/main/java/org/apache/calcite/plan/SubstitutionVisitor.java
##########
@@ -1914,18 +1915,36 @@ public static MutableAggregate permute(MutableAggregate aggregate,
         int i = targetGroupByIndexList.indexOf(inputIndex);
         projects.add(i);
       }
+      final List<AggregateCall> autoCreatedAggCalls = new ArrayList<>();
       for (AggregateCall aggregateCall : query.aggCalls) {
         int i = target.aggCalls.indexOf(aggregateCall);
         if (i < 0) {
-          return null;
+          final AggregateCall newAggCall = genAggCallWithTargetGrouping(
+              aggregateCall, targetGroupByIndexList);
+          if (newAggCall == null) {
+            return null;
+          } else {
+            // Here, we create a new `MutableAggregate` to return.
+            // So, we record this new agg-call.
+            autoCreatedAggCalls.add(newAggCall);
+          }
+        } else {
+          if (!autoCreatedAggCalls.isEmpty()) {
+            return null;
+          }

Review comment:
       @yanlin-Lynn I think that hinting on the reason why the two are not equivalent can be of great help for the contributor




-- 
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: commits-unsubscribe@calcite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org