You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by mo...@apache.org on 2022/05/26 14:43:25 UTC

[incubator-doris] branch master updated: [fix](function) If function adds type inference (#9728)

This is an automated email from the ASF dual-hosted git repository.

morningman pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-doris.git


The following commit(s) were added to refs/heads/master by this push:
     new 6698f63dec [fix](function) If function adds type inference (#9728)
6698f63dec is described below

commit 6698f63decec63835b0c789f67d01fb3a315ac27
Author: Stalary <st...@163.com>
AuthorDate: Thu May 26 22:43:18 2022 +0800

    [fix](function) If function adds type inference (#9728)
---
 .../src/main/java/org/apache/doris/analysis/FunctionCallExpr.java | 8 +++++++-
 .../query/sql_functions/conditional_functions/test_nullif.out     | 3 +++
 .../query/sql_functions/conditional_functions/test_nullif.groovy  | 1 +
 3 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/fe/fe-core/src/main/java/org/apache/doris/analysis/FunctionCallExpr.java b/fe/fe-core/src/main/java/org/apache/doris/analysis/FunctionCallExpr.java
index 75d9800dbc..3c2451630b 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/analysis/FunctionCallExpr.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/analysis/FunctionCallExpr.java
@@ -868,7 +868,13 @@ public class FunctionCallExpr extends Expr {
                 }
                 childTypes[i] = children.get(i).type;
             }
-
+            fn = getBuiltinFunction(analyzer, fnName.getFunction(), childTypes,
+                    Function.CompareMode.IS_NONSTRICT_SUPERTYPE_OF);
+        } else if (fnName.getFunction().equalsIgnoreCase("if")) {
+            Type[] childTypes = collectChildReturnTypes();
+            Type assignmentCompatibleType = ScalarType.getAssignmentCompatibleType(childTypes[1], childTypes[2], true);
+            childTypes[1] = assignmentCompatibleType;
+            childTypes[2] = assignmentCompatibleType;
             fn = getBuiltinFunction(analyzer, fnName.getFunction(), childTypes,
                     Function.CompareMode.IS_NONSTRICT_SUPERTYPE_OF);
         } else {
diff --git a/regression-test/data/query/sql_functions/conditional_functions/test_nullif.out b/regression-test/data/query/sql_functions/conditional_functions/test_nullif.out
index 43f0bfd3dd..ddf995a44a 100644
--- a/regression-test/data/query/sql_functions/conditional_functions/test_nullif.out
+++ b/regression-test/data/query/sql_functions/conditional_functions/test_nullif.out
@@ -4,3 +4,6 @@ true
 \N
 \N
 
+-- !select --
+2010-01-02T04:03:06
+
diff --git a/regression-test/suites/query/sql_functions/conditional_functions/test_nullif.groovy b/regression-test/suites/query/sql_functions/conditional_functions/test_nullif.groovy
index 91defc52ba..09b9fae42f 100644
--- a/regression-test/suites/query/sql_functions/conditional_functions/test_nullif.groovy
+++ b/regression-test/suites/query/sql_functions/conditional_functions/test_nullif.groovy
@@ -17,4 +17,5 @@
 
 suite("test_nullif", "query") {
     qt_select "select nullif(k6, \"false\") k from test_query_db.test order by k1"
+    qt_select "select if(c_date is null,c_timestamp,c_date) from regression_test.datetype where c_date is null and c_timestamp is not null"
 }


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