This is an automated email from the ASF dual-hosted git repository. morrysnow pushed a commit to branch branch-2.1 in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/branch-2.1 by this push: new dd86f9db6cc branch-2.1: [opt](Nereids) support bind asterisk in aggregate (#48006) dd86f9db6cc is described below commit dd86f9db6cc960f3e6be9448e8f434cbdbf9813e Author: morrySnow <zhangwen...@selectdb.com> AuthorDate: Tue Feb 18 16:31:31 2025 +0800 branch-2.1: [opt](Nereids) support bind asterisk in aggregate (#48006) --- .../doris/nereids/rules/analysis/BindExpression.java | 18 +++++++++++++++--- .../suites/nereids_syntax_p0/analyze_agg.groovy | 2 ++ 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/analysis/BindExpression.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/analysis/BindExpression.java index 4f94516cf26..44e507c76f0 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/analysis/BindExpression.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/analysis/BindExpression.java @@ -669,10 +669,22 @@ public class BindExpression implements AnalysisRuleFactory { SimpleExprAnalyzer aggOutputAnalyzer = buildSimpleExprAnalyzer( agg, cascadesContext, agg.children(), true, true); List<NamedExpression> boundAggOutput = aggOutputAnalyzer.analyzeToList(agg.getOutputExpressions()); - Supplier<Scope> aggOutputScopeWithoutAggFun = buildAggOutputScopeWithoutAggFun(boundAggOutput, cascadesContext); + ImmutableList.Builder<NamedExpression> boundProjectionsBuilder = ImmutableList.builder(); + for (int i = 0; i < boundAggOutput.size(); i++) { + NamedExpression output = boundAggOutput.get(i); + if (output instanceof BoundStar) { + List<Slot> slots = ((BoundStar) output).getSlots(); + boundProjectionsBuilder.addAll(slots); + } else { + boundProjectionsBuilder.add(output); + } + } + List<NamedExpression> boundProjections = boundProjectionsBuilder.build(); + Supplier<Scope> aggOutputScopeWithoutAggFun = buildAggOutputScopeWithoutAggFun( + boundProjections, cascadesContext); List<Expression> boundGroupBy = bindGroupBy( - agg, agg.getGroupByExpressions(), boundAggOutput, aggOutputScopeWithoutAggFun, cascadesContext); - return agg.withGroupByAndOutput(boundGroupBy, boundAggOutput); + agg, agg.getGroupByExpressions(), boundProjections, aggOutputScopeWithoutAggFun, cascadesContext); + return agg.withGroupByAndOutput(boundGroupBy, boundProjections); } private Plan bindRepeat(MatchingContext<LogicalRepeat<Plan>> ctx) { diff --git a/regression-test/suites/nereids_syntax_p0/analyze_agg.groovy b/regression-test/suites/nereids_syntax_p0/analyze_agg.groovy index 9a79df6bad5..af474c1ec76 100644 --- a/regression-test/suites/nereids_syntax_p0/analyze_agg.groovy +++ b/regression-test/suites/nereids_syntax_p0/analyze_agg.groovy @@ -88,4 +88,6 @@ suite("analyze_agg") { 1, x """ + + sql """select * from (select id from t2) t group by id""" } \ No newline at end of file --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org