[opt](optimizer) Remove unused code to unify code (#38918)
## Proposed changes
Now, Agg's child predicates will not spread to agg.
For example:
select a, sum(b)
from (
select a,b from t where a = 1 and b = 2
) t
group by a
`a = 1` in scan can be propagated to `a` of agg.
But `b = 2` in scan can not be propagated to `sum(b)` of agg.
Issue Number: #38905
<!--Describe your changes.-->
Co-authored-by: liutang123 <liulijia@gmail.com>
This commit is contained in:
@ -35,11 +35,9 @@ import org.apache.doris.nereids.util.ExpressionUtils;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.ImmutableSet.Builder;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.google.common.collect.Sets;
|
||||
|
||||
import java.util.IdentityHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
@ -107,21 +105,7 @@ public class PullUpPredicates extends PlanVisitor<ImmutableSet<Expression>, Void
|
||||
return cacheOrElse(aggregate, () -> {
|
||||
ImmutableSet<Expression> childPredicates = aggregate.child().accept(this, context);
|
||||
// TODO
|
||||
List<NamedExpression> outputExpressions = aggregate.getOutputExpressions();
|
||||
|
||||
Map<Expression, Slot> expressionSlotMap
|
||||
= Maps.newLinkedHashMapWithExpectedSize(outputExpressions.size());
|
||||
for (NamedExpression output : outputExpressions) {
|
||||
if (hasAgg(output)) {
|
||||
expressionSlotMap.putIfAbsent(
|
||||
output instanceof Alias ? output.child(0) : output, output.toSlot()
|
||||
);
|
||||
}
|
||||
}
|
||||
Expression expression = ExpressionUtils.replace(
|
||||
ExpressionUtils.and(Lists.newArrayList(childPredicates)),
|
||||
expressionSlotMap
|
||||
);
|
||||
Expression expression = ExpressionUtils.and(Lists.newArrayList(childPredicates));
|
||||
Set<Expression> predicates = Sets.newLinkedHashSet(ExpressionUtils.extractConjunction(expression));
|
||||
return getAvailableExpressions(predicates, aggregate);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user