Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
924060929 committed Jun 5, 2024
1 parent 3998063 commit cf0c4f0
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ && couldConvertToMulti(agg))
*/
RuleType.FOUR_PHASE_AGGREGATE_WITH_DISTINCT_WITH_FULL_DISTRIBUTE.build(
basePattern
.when(agg -> agg.everyDistinctArgumentsIsOne() && !agg.getGroupByExpressions().isEmpty())
.when(agg -> agg.everyDistinctArgumentNumIsOne() && !agg.getGroupByExpressions().isEmpty())
.when(agg ->
ImmutableSet.builder()
.addAll(agg.getGroupByExpressions())
Expand Down Expand Up @@ -1870,7 +1870,7 @@ private List<PhysicalHashAggregate<? extends Plan>> fourPhaseAggregateWithDistin
AggregateFunction nonDistinct = aggregateFunction
.withDistinctAndChildren(false, ImmutableList.copyOf(aggChild));
AggregateExpression nonDistinctAggExpr = new AggregateExpression(nonDistinct,
distinctLocalParam, aggregateFunction.child(0));
distinctLocalParam, aggregateFunction);
return nonDistinctAggExpr;
} else {
needUpdateSlot.add(aggregateFunction);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ default Set<Expression> getDistinctArguments() {
return distinctArguments.build();
}

/** everyDistinctAggregateFunctionIsOne */
default boolean everyDistinctArgumentsIsOne() {
/** everyDistinctArgumentNumIsOne */
default boolean everyDistinctArgumentNumIsOne() {
AtomicBoolean hasDistinctArguments = new AtomicBoolean(false);
for (NamedExpression outputExpression : getOutputExpressions()) {
boolean distinctArgumentSizeNotOne = outputExpression.anyMatch(expr -> {
Expand Down
4 changes: 3 additions & 1 deletion regression-test/suites/nereids_syntax_p0/agg_4_phase.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,6 @@ suite("agg_4_phase") {
qt_4phase (test_sql)

sql """select GROUP_CONCAT(distinct name, " ") from agg_4_phase_tbl;"""
}

sql """select /*+SET_VAR(disable_nereids_rules='TWO_PHASE_AGGREGATE_SINGLE_DISTINCT_TO_MULTI,THREE_PHASE_AGGREGATE_WITH_DISTINCT,FOUR_PHASE_AGGREGATE_WITH_DISTINCT')*/ GROUP_CONCAT(distinct name, " ") from agg_4_phase_tbl group by gender;"""
}

0 comments on commit cf0c4f0

Please sign in to comment.