[fix](planner)group_concat lost order by info in second phase merge agg (#16479)

This commit is contained in:
starocean999
2023-02-08 20:48:52 +08:00
committed by GitHub
parent a512469537
commit f0b0eedbc5
7 changed files with 21 additions and 4 deletions

View File

@ -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(

View File

@ -221,6 +221,10 @@ public class FunctionCallExpr extends Expr {
this.aggFnParams = aggFnParams;
}
public FunctionParams getAggFnParams() {
return aggFnParams;
}
public void setIsAnalyticFnCall(boolean v) {
isAnalyticFnCall = v;
}

View File

@ -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)