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 06:33:27 UTC

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

zstan commented on a change in pull request #2439:
URL: https://github.com/apache/calcite/pull/2439#discussion_r662016102



##########
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:
       running new test under debug, i found aggCall.getType() == BIGINT, while sumType == DECIMAL(19, 0) all these representation are identical as i can see, can you explain why we rise needTopCast flag in this case? Additionally i hope we need integration test highliting the bug, ServerTest possibly correct place for it. wdyt ?




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