[fix](Nereids): when child is Aggregate, don't infer Distinct for it (#21519)
This commit is contained in:
@ -50,7 +50,8 @@ public class InferSetOperatorDistinct extends OneRewriteRuleFactory {
|
||||
}
|
||||
|
||||
List<Plan> newChildren = setOperation.children().stream()
|
||||
.map(child -> new LogicalAggregate<>(ImmutableList.copyOf(child.getOutput()), true, child))
|
||||
.map(child -> isAgg(child) ? child
|
||||
: new LogicalAggregate<>(ImmutableList.copyOf(child.getOutput()), true, child))
|
||||
.collect(ImmutableList.toImmutableList());
|
||||
if (newChildren.equals(setOperation.children())) {
|
||||
return null;
|
||||
@ -59,6 +60,11 @@ public class InferSetOperatorDistinct extends OneRewriteRuleFactory {
|
||||
}).toRule(RuleType.INFER_SET_OPERATOR_DISTINCT);
|
||||
}
|
||||
|
||||
private boolean isAgg(Plan plan) {
|
||||
return plan instanceof LogicalAggregate || (plan instanceof LogicalProject && plan.child(
|
||||
0) instanceof LogicalAggregate);
|
||||
}
|
||||
|
||||
// if children exist NLJ, we can't infer distinct
|
||||
private boolean rejectNLJ(Plan plan) {
|
||||
if (plan instanceof LogicalProject) {
|
||||
|
||||
Reference in New Issue
Block a user