Skip to content

Commit

Permalink
[feat](nereids) add merge aggregate rule
Browse files Browse the repository at this point in the history
  • Loading branch information
feiniaofeiafei committed Mar 10, 2024
1 parent bdbbd54 commit 6fe78ae
Showing 1 changed file with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet;

import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
Expand All @@ -44,7 +45,7 @@
public class MergeAggregate implements RewriteRuleFactory {
private static final ImmutableSet<String> ALLOW_MERGE_AGGREGATE_FUNCTIONS =
ImmutableSet.of("min", "max", "sum", "any_value");
private Map<ExprId, AggregateFunction> innerAggExprIdToAggFunc;
private Map<ExprId, AggregateFunction> innerAggExprIdToAggFunc = new HashMap<>();

@Override
public List<Rule> buildRules() {
Expand Down Expand Up @@ -136,7 +137,8 @@ private NamedExpression rewriteAggregateFunction(NamedExpression e,
});
}

boolean commonCheck(LogicalAggregate<? extends Plan> outerAgg, LogicalAggregate<Plan> innerAgg, boolean sameGroupBy) {
boolean commonCheck(LogicalAggregate<? extends Plan> outerAgg, LogicalAggregate<Plan> innerAgg,
boolean sameGroupBy) {
innerAggExprIdToAggFunc = innerAgg.getOutputExpressions().stream()
.filter(expr -> (expr instanceof Alias) && (expr.child(0) instanceof AggregateFunction))
.collect(Collectors.toMap(NamedExpression::getExprId, value -> (AggregateFunction) value.child(0),
Expand Down

0 comments on commit 6fe78ae

Please sign in to comment.