morrySnow commented on code in PR #10499: URL: https://github.com/apache/doris/pull/10499#discussion_r910830149
########## fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/translator/PhysicalPlanTranslator.java: ########## @@ -94,17 +100,20 @@ public PlanFragment visitPhysicalAggregation( List<Expression> groupByExpressionList = physicalAggregation.getGroupByExprList(); ArrayList<Expr> execGroupingExpressions = groupByExpressionList.stream() - .map(e -> ExpressionConverter.convert(e, context)).collect(Collectors.toCollection(ArrayList::new)); + .map(e -> ExpressionTranslator.convert(e, context)).collect(Collectors.toCollection(ArrayList::new)); List<NamedExpression> outputExpressionList = physicalAggregation.getOutputExpressionList(); - // TODO: agg function could be other expr type either ArrayList<FunctionCallExpr> execAggExpressions = outputExpressionList.stream() - .map(e -> (FunctionCallExpr) ExpressionConverter.convert(e, context)) + .map(FindFunction::find + ) Review Comment: this parenthesis‘s position is weird ########## fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/FindFunction.java: ########## @@ -0,0 +1,55 @@ +// 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.trees.expressions; + +import org.apache.doris.nereids.trees.expressions.functions.BoundFunction; + +import java.util.ArrayList; +import java.util.List; + +/** + * Find all function call in the given expression tree. + */ +public class FindFunction extends ExpressionVisitor<Void, List<BoundFunction>> { + + private static final FindFunction findFunction = new FindFunction(); Review Comment: ```suggestion private static final FindFunction INSTANCE = new FindFunction(); ``` ########## fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/translator/ExpressionTranslator.java: ########## @@ -45,12 +58,12 @@ * Used to convert expression of new optimizer to stale expr. */ @SuppressWarnings("rawtypes") -public class ExpressionConverter extends DefaultExpressionVisitor<Expr, PlanTranslatorContext> { +public class ExpressionTranslator extends DefaultExpressionVisitor<Expr, PlanTranslatorContext> { - public static ExpressionConverter converter = new ExpressionConverter(); + public static ExpressionTranslator translator = new ExpressionTranslator(); public static Expr convert(Expression expression, PlanTranslatorContext planContext) { Review Comment: ```suggestion public static Expr translate(Expression expression, PlanTranslatorContext planContext) { ``` ########## fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/translator/PhysicalPlanTranslator.java: ########## @@ -94,17 +100,20 @@ public PlanFragment visitPhysicalAggregation( List<Expression> groupByExpressionList = physicalAggregation.getGroupByExprList(); ArrayList<Expr> execGroupingExpressions = groupByExpressionList.stream() - .map(e -> ExpressionConverter.convert(e, context)).collect(Collectors.toCollection(ArrayList::new)); + .map(e -> ExpressionTranslator.convert(e, context)).collect(Collectors.toCollection(ArrayList::new)); List<NamedExpression> outputExpressionList = physicalAggregation.getOutputExpressionList(); - // TODO: agg function could be other expr type either ArrayList<FunctionCallExpr> execAggExpressions = outputExpressionList.stream() - .map(e -> (FunctionCallExpr) ExpressionConverter.convert(e, context)) + .map(FindFunction::find + ) + .flatMap(List::stream) + .filter(x -> x instanceof AggregateFunction) Review Comment: ```suggestion .filter(AggregateFunction.class::isInstance) ``` -- 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