danny0405 commented on a change in pull request #1741: [CALCITE-3721] Filter of
distinct aggregate call is lost after applyi…
URL: https://github.com/apache/calcite/pull/1741#discussion_r366252358
##########
File path:
core/src/main/java/org/apache/calcite/rel/rules/AggregateExpandDistinctAggregatesRule.java
##########
@@ -470,21 +492,20 @@ private void rewriteUsingGroupingSets(RelOptRuleCall
call,
if (!aggCall.isDistinct()) {
aggregation = SqlStdOperatorTable.MIN;
newArgList = ImmutableIntList.of(x++);
- newFilterArg = filters.get(aggregate.getGroupSet());
+ newFilterArg = filters.get(Pair.of(aggregate.getGroupSet(), -1));
} else {
aggregation = aggCall.getAggregation();
newArgList = remap(fullGroupSet, aggCall.getArgList());
- newFilterArg =
- filters.get(
- ImmutableBitSet.of(aggCall.getArgList())
- .setIf(aggCall.filterArg, aggCall.filterArg >= 0)
- .union(aggregate.getGroupSet()));
+ final ImmutableBitSet groupSet =
ImmutableBitSet.of(aggCall.getArgList())
+ .setIf(aggCall.filterArg, aggCall.filterArg >= 0)
Review comment:
Maybe we can reuse the group set for each agg call.
----------------------------------------------------------------
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]
With regards,
Apache Git Services