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/07/01 11:22:00 UTC

[GitHub] [calcite] tledkov-gridgain commented on a change in pull request #2439: CALCITE-4652 AggregateExpandDistinctAggregatesRule must cast top aggregates to original type

tledkov-gridgain commented on a change in pull request #2439:
URL: https://github.com/apache/calcite/pull/2439#discussion_r662190441



##########
File path: core/src/main/java/org/apache/calcite/rel/rules/AggregateExpandDistinctAggregatesRule.java
##########
@@ -366,12 +370,18 @@ private static RelBuilder convertSingletonDistinct(RelBuilder relBuilder,
         final int arg = bottomGroups.size() + nonDistinctAggCallProcessedSoFar;
         final List<Integer> newArgs = ImmutableList.of(arg);
         if (aggCall.getAggregation().getKind() == SqlKind.COUNT) {
+          RelDataTypeFactory typeFactory = aggregate.getCluster().getTypeFactory();
+          RelDataType sumType = typeFactory.getTypeSystem().deriveSumType(typeFactory,
+              aggCall.getType());
+          needTopCast |= !sumType.equals(aggCall.getType());

Review comment:
       Because the transformation rule must do an equivalent transformation. So, the type of the output row must be the same as that of the original node. DECIMAL and BIGINT are different types.




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