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 2019/10/28 13:10:40 UTC

[GitHub] [incubator-doris] imay commented on a change in pull request #2087: Add the cast function for if function in outer join

imay commented on a change in pull request #2087: Add the cast function for if function in outer join
URL: https://github.com/apache/incubator-doris/pull/2087#discussion_r339553042
 
 

 ##########
 File path: fe/src/main/java/org/apache/doris/analysis/TupleIsNullPredicate.java
 ##########
 @@ -119,16 +119,25 @@ public boolean equals(Object o) {
      * if required to make expr nullable. Otherwise, returns expr.
      */
     public static Expr wrapExpr(Expr expr, List<TupleId> tids, Analyzer analyzer)
-        throws UserException {
-    if (!requiresNullWrapping(expr, analyzer)) {
-        return expr;
-    }
+            throws UserException {
+        if (!requiresNullWrapping(expr, analyzer)) {
+            return expr;
+        }
         List<Expr> params = Lists.newArrayList();
         params.add(new TupleIsNullPredicate(tids));
         params.add(new NullLiteral());
         params.add(expr);
         Expr ifExpr = new FunctionCallExpr("if", params);
         ifExpr.analyzeNoThrow(analyzer);
+        // The type of function which is different from the type of expr will return the incorrect result in query.
+        // Example:
+        //   the type of expr is date
+        //   the type of function is int
+        //   So, the upper fragment will receive a int value instead of date while the result expr is date.
+        // If there is no cast function, the result of query will be incorrect.
+        if (expr.getType() != ifExpr.getType()) {
 
 Review comment:
   I think it should be .equal() or .getPrimitiveType()

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


With regards,
Apache Git Services

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