This is an automated email from the ASF dual-hosted git repository. morrysnow pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/master by this push: new f0b0eedbc5 [fix](planner)group_concat lost order by info in second phase merge agg (#16479) f0b0eedbc5 is described below commit f0b0eedbc53add11766d4909ef7f3ed5151d09ff Author: starocean999 <40539150+starocean...@users.noreply.github.com> AuthorDate: Wed Feb 8 20:48:52 2023 +0800 [fix](planner)group_concat lost order by info in second phase merge agg (#16479) --- .../src/main/java/org/apache/doris/analysis/AggregateInfo.java | 7 +++++-- .../src/main/java/org/apache/doris/analysis/FunctionCallExpr.java | 4 ++++ .../doris/nereids/trees/expressions/functions/agg/GroupConcat.java | 2 -- regression-test/data/nereids_p0/group_concat/test_group_concat.out | 3 +++ regression-test/data/query_p0/group_concat/test_group_concat.out | 3 +++ .../suites/nereids_p0/group_concat/test_group_concat.groovy | 3 +++ .../suites/query_p0/group_concat/test_group_concat.groovy | 3 +++ 7 files changed, 21 insertions(+), 4 deletions(-) diff --git a/fe/fe-core/src/main/java/org/apache/doris/analysis/AggregateInfo.java b/fe/fe-core/src/main/java/org/apache/doris/analysis/AggregateInfo.java index 904cb0848a..33701b8517 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/analysis/AggregateInfo.java +++ b/fe/fe-core/src/main/java/org/apache/doris/analysis/AggregateInfo.java @@ -558,8 +558,10 @@ public final class AggregateInfo extends AggregateInfoBase { Preconditions.checkState(inputExpr.isAggregateFunction()); Expr aggExprParam = new SlotRef(inputDesc.getSlots().get(i + getGroupingExprs().size())); - FunctionCallExpr aggExpr = FunctionCallExpr.createMergeAggCall( - inputExpr, Lists.newArrayList(aggExprParam), inputExpr.getFnParams().exprs()); + FunctionParams fnParams = inputExpr.getAggFnParams(); + FunctionCallExpr aggExpr = + FunctionCallExpr.createMergeAggCall(inputExpr, Lists.newArrayList(aggExprParam), + fnParams != null ? fnParams.exprs() : inputExpr.getFnParams().exprs()); aggExpr.analyzeNoThrow(analyzer); // do not need analyze in merge stage, just do mark for BE get right function aggExpr.setOrderByElements(inputExpr.getOrderByElements()); @@ -691,6 +693,7 @@ public final class AggregateInfo extends AggregateInfoBase { new SlotRef(inputDesc.getSlots().get(i + getGroupingExprs().size())); FunctionCallExpr aggExpr = FunctionCallExpr.createMergeAggCall( inputExpr, Lists.newArrayList(aggExprParam), inputExpr.getFnParams().exprs()); + aggExpr.setOrderByElements(inputExpr.getOrderByElements()); secondPhaseAggExprs.add(aggExpr); } Preconditions.checkState( diff --git a/fe/fe-core/src/main/java/org/apache/doris/analysis/FunctionCallExpr.java b/fe/fe-core/src/main/java/org/apache/doris/analysis/FunctionCallExpr.java index f4d6ea358c..89c7f3a7fe 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/analysis/FunctionCallExpr.java +++ b/fe/fe-core/src/main/java/org/apache/doris/analysis/FunctionCallExpr.java @@ -221,6 +221,10 @@ public class FunctionCallExpr extends Expr { this.aggFnParams = aggFnParams; } + public FunctionParams getAggFnParams() { + return aggFnParams; + } + public void setIsAnalyticFnCall(boolean v) { isAnalyticFnCall = v; } diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/agg/GroupConcat.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/agg/GroupConcat.java index d691d2108a..20e6c29c62 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/agg/GroupConcat.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/agg/GroupConcat.java @@ -41,8 +41,6 @@ public class GroupConcat extends NullableAggregateFunction public static final List<FunctionSignature> SIGNATURES = ImmutableList.of( FunctionSignature.ret(VarcharType.SYSTEM_DEFAULT).args(VarcharType.SYSTEM_DEFAULT), - FunctionSignature.ret(VarcharType.SYSTEM_DEFAULT) - .args(VarcharType.SYSTEM_DEFAULT, VarcharType.SYSTEM_DEFAULT), FunctionSignature.ret(VarcharType.SYSTEM_DEFAULT) .varArgs(VarcharType.SYSTEM_DEFAULT, AnyDataType.INSTANCE), FunctionSignature.ret(VarcharType.SYSTEM_DEFAULT) diff --git a/regression-test/data/nereids_p0/group_concat/test_group_concat.out b/regression-test/data/nereids_p0/group_concat/test_group_concat.out index 9c6ff6c8b4..9569bd5b32 100644 --- a/regression-test/data/nereids_p0/group_concat/test_group_concat.out +++ b/regression-test/data/nereids_p0/group_concat/test_group_concat.out @@ -85,3 +85,6 @@ false 25699 1989 2147483647 255:1991:32767:32767 +-- !select -- +12 false, false, false, false, false, false, false, false, true, true, true, true, true, true, true + diff --git a/regression-test/data/query_p0/group_concat/test_group_concat.out b/regression-test/data/query_p0/group_concat/test_group_concat.out index 9c6ff6c8b4..38f6f95ca3 100644 --- a/regression-test/data/query_p0/group_concat/test_group_concat.out +++ b/regression-test/data/query_p0/group_concat/test_group_concat.out @@ -45,6 +45,9 @@ false 25699 1989 2147483647 255:1991:32767:32767 +-- !select -- +12 false, false, false, false, false, false, false, false, true, true, true, true, true, true, true + -- !select -- \N \N 103 255 diff --git a/regression-test/suites/nereids_p0/group_concat/test_group_concat.groovy b/regression-test/suites/nereids_p0/group_concat/test_group_concat.groovy index 9eb415465a..8d48f86b2c 100644 --- a/regression-test/suites/nereids_p0/group_concat/test_group_concat.groovy +++ b/regression-test/suites/nereids_p0/group_concat/test_group_concat.groovy @@ -55,4 +55,7 @@ suite("test_group_concat") { qt_select """ SELECT abs(k3), group_concat(distinct cast(abs(k2) as char), ":" order by abs(k1), k2) FROM test_query_db.baseall group by abs(k3) order by abs(k3); """ + qt_select """ + SELECT count(distinct k7), group_concat(k6 order by k6) FROM test_query_db.baseall; + """ } diff --git a/regression-test/suites/query_p0/group_concat/test_group_concat.groovy b/regression-test/suites/query_p0/group_concat/test_group_concat.groovy index dcd8d5cc85..e423f4f4d1 100644 --- a/regression-test/suites/query_p0/group_concat/test_group_concat.groovy +++ b/regression-test/suites/query_p0/group_concat/test_group_concat.groovy @@ -37,6 +37,9 @@ suite("test_group_concat") { qt_select """ SELECT abs(k3), group_concat(distinct cast(abs(k2) as char), ":" order by abs(k1), k2) FROM test_query_db.baseall group by abs(k3) order by abs(k3); """ + qt_select """ + SELECT count(distinct k7), group_concat(k6 order by k6) FROM test_query_db.baseall; + """ sql "set enable_nereids_planner=true" sql "set enable_vectorized_engine=true" --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org