diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/implementation/AggregateStrategies.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/implementation/AggregateStrategies.java index 71f96ef0496625..937515ad8b53ce 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/implementation/AggregateStrategies.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/implementation/AggregateStrategies.java @@ -82,7 +82,6 @@ import com.google.common.collect.Lists; import com.google.common.collect.Sets; -import java.util.ArrayList; import java.util.Collection; import java.util.HashMap; import java.util.List; @@ -334,20 +333,11 @@ private LogicalProject pushDownCountWithoutSlotRef( return canNotPush; } } - List projectExpr = new ArrayList<>(); - for (Expression p : project.getProjects()) { - projectExpr.addAll(Project.collectExpressions(p)); - } - boolean noSlotRef = true; - for (Expression expr : projectExpr) { - if (expr instanceof SlotReference) { - noSlotRef = false; - break; + for (Expression e : project.getProjects()) { + if (e.anyMatch(SlotReference.class::isInstance)) { + return canNotPush; } } - if (!noSlotRef) { - return canNotPush; - } PhysicalOlapScan physicalOlapScan = (PhysicalOlapScan) new LogicalOlapScanToPhysicalOlapScan() .build() diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/algebra/Project.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/algebra/Project.java index 287d47131767c3..15b095bee3bd28 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/algebra/Project.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/algebra/Project.java @@ -31,7 +31,6 @@ import com.google.common.collect.ImmutableMap; -import java.util.ArrayList; import java.util.Collection; import java.util.List; import java.util.Map; @@ -128,17 +127,4 @@ default boolean isAllSlots() { } return true; } - - static List collectExpressions(Expression expr) { - List expressions = new ArrayList<>(); - collectExpressionsRecursive(expr, expressions); - return expressions; - } - - static void collectExpressionsRecursive(Expression expr, List expressions) { - expressions.add(expr); - for (Expression child : expr.children()) { - collectExpressionsRecursive(child, expressions); - } - } }