You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by GitBox <gi...@apache.org> on 2020/04/27 13:02:30 UTC

[GitHub] [incubator-doris] morningman commented on a change in pull request #3396: (#3395)calculate 'case when expr' when possible

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:
users@infra.apache.org



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