github-actions[bot] commented on code in PR #65846:
URL: https://github.com/apache/doris/pull/65846#discussion_r3702039317


##########
fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/SetPreAggStatus.java:
##########
@@ -94,8 +94,22 @@ public static class PreAggInfoContext {
 
         private Map<Slot, Expression> replaceMap = new HashMap<>();
 
-        private void setReplaceMap(Map<Slot, Expression> replaceMap) {
-            this.replaceMap = replaceMap;
+        private void setReplaceMap(Map<Slot, Expression> newReplaceMap) {
+            // merge instead of replace: sibling projects under a join share 
one
+            // PreAggInfoContext, and a full replacement would lose mappings 
from
+            // the sibling. merge keeps all entries; new entries shadow old 
ones
+            // by putAll semantics so a chain of projects still resolves 
correctly.
+            //
+            // Before merging, resolve the new aliases' producers through the
+            // existing replaceMap so that upper-layer aliases reference base 
table
+            // columns directly instead of intermediate computed aliases.
+            Map<Slot, Expression> merged = new HashMap<>(this.replaceMap);
+            for (Map.Entry<Slot, Expression> entry : newReplaceMap.entrySet()) 
{
+                Expression resolvedProducer = ExpressionUtils.replace(

Review Comment:
   The current recovery still does not take the conservative-OFF path requested 
here. When composing x14 exceeds the expression limit, line 127 stores the raw 
x13+x13 producer but leaves hasUnresolvedExpression false. 
ExpressionUtils.replace is top-down short-circuit, so replacing max(x14) later 
inserts that raw producer without descending into x13; the local scan 
intersection is then empty and the other-table MAX whitelist returns ON. If the 
chain starts from a SUM value column and the same full key has v7=1 and v7=2 in 
separate rowsets, OFF evaluates the expansion after merging to 3 while ON takes 
MAX over expansions of 1 and 2. Please set the unresolved flag in this catch 
(or retain explicit lineage) and add the duplicate-row value-chain regression.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to