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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to