morningman commented on a change in pull request #3396:
URL: https://github.com/apache/incubator-doris/pull/3396#discussion_r415792585



##########
File path: fe/src/main/java/org/apache/doris/rewrite/FoldConstantsRule.java
##########
@@ -48,6 +50,12 @@
 
     @Override
     public Expr apply(Expr expr, Analyzer analyzer) throws AnalysisException {
+        // evaluate case when expr
+        if (expr instanceof CaseExpr && expr.getChild(0) instanceof 
BoolLiteral) {

Review comment:
       This is not right, the CaseExpr has multi child
   1. optional case expr
   2. optional list<when expr, then expr>
   3. optional else expr.
   
   The following SQL will return wrong result after applying your rewrite rule:
   ```
   select case when false then 2 when true then 3 else 0 end;
   ```
   Expect: 3, return 1.
   




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

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



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

Reply via email to