morrySnow commented on code in PR #61813:
URL: https://github.com/apache/doris/pull/61813#discussion_r2999788954


##########
fe/fe-core/src/main/java/org/apache/doris/nereids/rules/analysis/ExpressionAnalyzer.java:
##########
@@ -875,6 +875,33 @@ public Expression 
visitComparisonPredicate(ComparisonPredicate cp, ExpressionRew
 
     @Override
     public Expression visitCaseWhen(CaseWhen caseWhen, 
ExpressionRewriteContext context) {
+        if (caseWhen.getValue().isPresent()) {
+            // Simple case: CASE value WHEN cond THEN result ...
+            // Analyze value once, then construct EqualTo(analyzedValue, 
analyzedCond) per WhenClause
+            Expression analyzedValue = caseWhen.getValue().get().accept(this, 
context);
+
+            List<WhenClause> newWhenClauses = new ArrayList<>();
+            for (WhenClause whenClause : caseWhen.getWhenClauses()) {
+                Expression operand = whenClause.getOperand().accept(this, 
context);
+                Expression result = whenClause.getResult().accept(this, 
context);
+                EqualTo rawEqualTo = new EqualTo(analyzedValue, operand);
+                registerPlaceholderIdToSlot(rawEqualTo, context, 
analyzedValue, operand);
+                Expression equalTo = 
TypeCoercionUtils.processComparisonPredicate(rawEqualTo);

Review Comment:
   Good catch. Removed the call since it's dead code: rawEqualTo is constructed 
with already-analyzed children (Placeholders would already be resolved by 
.accept(this, context)). Fixed in force push.



-- 
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