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



##########
File path: fe/src/main/java/org/apache/doris/analysis/CaseExpr.java
##########
@@ -251,4 +257,72 @@ public void analyzeImpl(Analyzer analyzer) throws 
AnalysisException {
         }
         return exprs;
     }
+
+    // this method just compare literal value and not completely consistent 
with be,for two cases
+    // 1 not deal float
+    // 2 just compare literal value with same type. for a example sql 'select 
case when 123 then '1' else '2' end as col'
+    //      for be will return '1', because be only regard 0 as false
+    //      but for current LiteralExpr.compareLiteral, `123`' won't be regard 
as true
+    //  the case which two values has different type left to be
+    public static Expr computeCaseExpr(CaseExpr expr) {
+        LiteralExpr caseExpr;
+        int startIndex = 0;
+        int size = expr.getChildren().size() - 1;
+        if (expr.hasCaseExpr()) {
+            // just deal literal here
+            // and avoid `float compute` in java,float should be dealt in be
+            Expr caseChildExpr = expr.getChild(0);
+            if (!caseChildExpr.isLiteral()
+                    || caseChildExpr instanceof DecimalLiteral || 
caseChildExpr instanceof FloatLiteral) {
+                return expr;
+            }
+            caseExpr = (LiteralExpr) expr.getChild(0);
+            startIndex++;
+            size--;
+        } else {
+            caseExpr = new BoolLiteral(true);
+        }
+
+        if (expr.hasElseExpr) {
+            size--;
+        }
+
+        //pre return when the `when expr` can't be converted to constants

Review comment:
       👌




----------------------------------------------------------------
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:
[email protected]



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

Reply via email to