diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/AdjustTopNProject.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/AdjustTopNProject.java index 29dafc9e7fa2be..7cc1456382268f 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/AdjustTopNProject.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/AdjustTopNProject.java @@ -56,7 +56,7 @@ public class AdjustTopNProject extends OneRewriteRuleFactory { @Override public Rule build() { - return logicalTopN(logicalProject()) + return logicalTopN(logicalProject(logicalAggregate())) .then(topN -> adjust(topN)).toRule(RuleType.ADJUST_TOPN_PROJECT); }