github-actions[bot] commented on code in PR #69111:
URL: https://github.com/apache/doris/pull/69111#discussion_r4291193207
##########
fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/ConstantPropagation.java:
##########
@@ -115,9 +152,15 @@ public Plan visitLogicalHaving(LogicalHaving<? extends
Plan> having, CascadesCon
}
}
+ /** Whether this expression is an output of a CTE producer body, whose
exprId has to stay stable. */
+ private boolean isCteProducerOutput(Expression expr) {
+ return expr instanceof Slot &&
cteProducerOutputExprIds.contains(((Slot) expr).getExprId());
+ }
+
@Override
public Plan visitLogicalProject(LogicalProject<? extends Plan> project,
CascadesContext context) {
project = visitChildren(this, project, context);
+ project = (LogicalProject<? extends Plan>)
exprIdRewriter.rewriteExpr(project, replacedExprIds);
Review Comment:
[P2] Remap slots inside guarded MERGE expressions
For a nonunique source with varying `v`, a MERGE using `(SELECT k,v,SUM(x) s
FROM src WHERE k=5 GROUP BY k,v) q`, `ON d.id=q.v`, matched `UPDATE SET
value=d.value+q.k+q.s` and unmatched `INSERT(id,value) VALUES(q.v,q.k+q.s)`
reaches this reduced tree:
```text
Project(ShortCircuitIf(label=0, d.value + q.k#old + q.s, ...))
... -> RightOuterJoin(target,
Aggregate(group=k#old,v; out=k#old,v,s)
-> Filter(k#old=5) -> Scan)
```
ConstantPropagation materializes `5 AS k#fresh` and refreshes forwarding
outputs, but this helper uses `ExpressionRewrite.bottomUp(ReplaceRule)`.
`ExpressionBottomUpRewriter` skips children of
`RequiresShortCircuitEvaluation`, which includes MERGE's `ShortCircuitIf`; its
SlotReference/Alias rules therefore never reach `q.k#old` in the assignment.
The child no longer outputs that ID, and its data traits no longer contain it,
so subsequent constant replacement cannot repair the reference and final slot
validation rejects the MERGE. Use structural ID traversal that enters guarded
branches without evaluating them, and add a MERGE planning test for this shape.
--
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]