Skip to content

Commit

Permalink
[fix](Nereids) fix group concat (apache#33091)
Browse files Browse the repository at this point in the history
Fix failed in regression_test/suites/query_p0/group_concat/test_group_concat.groovy

select
group_concat( distinct b1, '?'), group_concat( distinct b3, '?')
from
table_group_concat
group by
b2

exception:

lowestCostPlans with physicalProperties(GATHER) doesn't exist in root group

The root cause is '?' is push down to slot by NormalizeAggregate, AggregateStrategies treat the slot as a distinct parameter and generate a invalid PhysicalHashAggregate, and then reject by ChildOutputPropertyDeriver.

I fix this bug by avoid push down literal to slot in NormalizeAggregate, and forbidden generate stream aggregate node when group by slots is empty

(cherry picked from commit e7d6697)
  • Loading branch information
924060929 committed May 24, 2024
1 parent 33c783f commit 5689908
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -182,11 +182,11 @@ private LogicalPlan normalizeAgg(LogicalAggregate<Plan> aggregate, LogicalHaving
);

Set<Expression> needPushSelf = Sets.union(
categorizedNoDistinctAggsChildren.getOrDefault(true, new HashSet<>()),
categorizedDistinctAggsChildren.getOrDefault(true, new HashSet<>()));
categorizedNoDistinctAggsChildren.getOrDefault(true, ImmutableSet.of()),
categorizedDistinctAggsChildren.getOrDefault(true, ImmutableSet.of()));
Set<Slot> needPushInputSlots = ExpressionUtils.getInputSlotSet(Sets.union(
categorizedNoDistinctAggsChildren.getOrDefault(false, new HashSet<>()),
categorizedDistinctAggsChildren.getOrDefault(false, new HashSet<>())));
categorizedNoDistinctAggsChildren.getOrDefault(false, ImmutableSet.of()),
categorizedDistinctAggsChildren.getOrDefault(false, ImmutableSet.of())));

Set<Alias> existsAlias =
ExpressionUtils.mutableCollect(aggregateOutput, Alias.class::isInstance);
Expand Down

0 comments on commit 5689908

Please sign in to comment.