Kikyou1997 commented on code in PR #10412: URL: https://github.com/apache/doris/pull/10412#discussion_r906747888
########## fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/AggregateRewrite.java: ########## @@ -0,0 +1,93 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +package org.apache.doris.nereids.rules.rewrite; + +import org.apache.doris.analysis.FunctionName; +import org.apache.doris.catalog.AggregateFunction; +import org.apache.doris.catalog.Catalog; +import org.apache.doris.catalog.Function; +import org.apache.doris.catalog.Function.CompareMode; +import org.apache.doris.catalog.Type; +import org.apache.doris.nereids.operators.Operator; +import org.apache.doris.nereids.operators.plans.logical.LogicalAggregation; +import org.apache.doris.nereids.rules.Rule; +import org.apache.doris.nereids.rules.RuleType; +import org.apache.doris.nereids.trees.analysis.FunctionParams; +import org.apache.doris.nereids.trees.expressions.Expression; +import org.apache.doris.nereids.trees.expressions.FunctionCall; +import org.apache.doris.nereids.trees.expressions.NamedExpression; +import org.apache.doris.nereids.trees.plans.Plan; +import org.apache.doris.nereids.types.DataType; + +import com.google.common.base.Preconditions; + +import java.util.List; +import java.util.stream.Collectors; + +/** + * Used to generate the merge agg node for distributed execution. + */ +public class AggregateRewrite extends OneRewriteRuleFactory { + + @Override + public Rule<Plan> build() { + return logicalAggregation().thenApply(ctx -> { + Plan plan = ctx.root; + Operator operator = plan.getOperator(); + LogicalAggregation agg = (LogicalAggregation) operator; + List<NamedExpression> namedExpressionList = agg.getOutputExpressions(); + List<NamedExpression> intermediateAggExpressionList = agg.getOutputExpressions(); + for (NamedExpression namedExpression : namedExpressionList) { Review Comment: I think so, but I haven't figured out how to get the `SlotReference` properly yet. As `SlotReference` is a LeafExpression, it can't have any child which means If the namedExpression is a `SlotReference` type, then it shouldn' have any child as `FunctionCall`. If the slotRef is calculated by `computeOutput`, the update of `FunctionCall` would be enough, I think the invocation chain is like below: ``` LogicalAgg::computeOutput -> Alias::computeOutput -> FunctionCall::getDataType ``` -- 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-unsubscr...@doris.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org