You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by yi...@apache.org on 2026/05/21 05:24:33 UTC

(doris) branch branch-4.1 updated: branch-4.1: [fix](nereids) Fix pre-aggregation context leakage across join branches #63357 (#63433)

This is an automated email from the ASF dual-hosted git repository.

yiguolei pushed a commit to branch branch-4.1
in repository https://gitbox.apache.org/repos/asf/doris.git


The following commit(s) were added to refs/heads/branch-4.1 by this push:
     new 7cac67921e2 branch-4.1: [fix](nereids) Fix pre-aggregation context leakage across join branches #63357 (#63433)
7cac67921e2 is described below

commit 7cac67921e2434cc48448464f45702b4ad5d2885
Author: github-actions[bot] <41...@users.noreply.github.com>
AuthorDate: Thu May 21 13:24:26 2026 +0800

    branch-4.1: [fix](nereids) Fix pre-aggregation context leakage across join branches #63357 (#63433)
    
    Cherry-picked from #63357
    
    Co-authored-by: lw112 <13...@users.noreply.github.com>
---
 .../nereids/rules/rewrite/SetPreAggStatus.java     |  1 +
 .../nereids_rules_p0/set_preagg/set_preagg.groovy  | 25 +++++++++++++++++++---
 2 files changed, 23 insertions(+), 3 deletions(-)

diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/SetPreAggStatus.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/SetPreAggStatus.java
index 7ae49fc6ec8..9b152efbb20 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/SetPreAggStatus.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/SetPreAggStatus.java
@@ -207,6 +207,7 @@ public class SetPreAggStatus extends DefaultPlanRewriter<Stack<SetPreAggStatus.P
         Plan plan = super.visit(logicalAggregate, context);
         if (!context.isEmpty()) {
             PreAggInfoContext preAggInfoContext = context.pop();
+            preAggInfoContext.olapScanIds.retainAll(logicalAggregate.child().getInputRelations());
             preAggInfoContext.addAggregateFunctions(logicalAggregate.getAggregateFunctions());
             preAggInfoContext.addGroupByExpresssions(logicalAggregate.getGroupByExpressions());
             for (RelationId id : preAggInfoContext.olapScanIds) {
diff --git a/regression-test/suites/nereids_rules_p0/set_preagg/set_preagg.groovy b/regression-test/suites/nereids_rules_p0/set_preagg/set_preagg.groovy
index 106f05b8f13..888892bc9c4 100644
--- a/regression-test/suites/nereids_rules_p0/set_preagg/set_preagg.groovy
+++ b/regression-test/suites/nereids_rules_p0/set_preagg/set_preagg.groovy
@@ -269,7 +269,9 @@ suite("set_preagg") {
             group by preagg_t3.k2, t12.k2
             order by 1, 2;
         """)
-        notContains "PREAGGREGATION: OFF"
+        contains "(preagg_t1), PREAGGREGATION: ON"
+        contains "(preagg_t2), PREAGGREGATION: ON"
+        contains "(preagg_t3), PREAGGREGATION: OFF"
     }
 
     explain {
@@ -287,7 +289,9 @@ suite("set_preagg") {
             group by preagg_t3.k2, t12.k2
             order by 1, 2;
         """)
-        notContains "PREAGGREGATION: OFF"
+        contains "(preagg_t1), PREAGGREGATION: ON"
+        contains "(preagg_t2), PREAGGREGATION: ON"
+        contains "(preagg_t3), PREAGGREGATION: OFF"
     }
 
     explain {
@@ -307,6 +311,21 @@ suite("set_preagg") {
         """)
         contains "(preagg_t1), PREAGGREGATION: ON"
         contains "(preagg_t2), PREAGGREGATION: OFF. Reason: can't turn preAgg on because aggregate function sum"
-        contains "(preagg_t3), PREAGGREGATION: OFF. Reason: can't turn preAgg on because aggregate function sum"
+        contains "(preagg_t3), PREAGGREGATION: OFF"
+    }
+
+    explain {
+        sql("""
+            select cw.k1, cw.k2, cw.v7, cw.v9
+            from preagg_t1 cw
+            inner join (
+                select k1, k2, max(v9) as v9
+                from preagg_t1
+                where k1 in (1, 2)
+                group by k1, k2
+            ) mw on cw.k1 = mw.k1 and cw.v9 = mw.v9;
+        """)
+        contains "(preagg_t1), PREAGGREGATION: OFF. Reason: No valid aggregate on scan."
+        contains "(preagg_t1), PREAGGREGATION: ON"
     }
 }


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org