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/27 15:08:46 UTC

[incubator-doris] 03/08: [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 dev-1.0.1
in repository https://gitbox.apache.org/repos/asf/incubator-doris.git

commit 37410280c8be2dc50ec155d3270456f48de2acc9
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 +++++++-
 regression-test/data/correctness/test_select_constant.out         | 3 +++
 2 files changed, 10 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 bc30b9d5f9..fc733bd636 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
@@ -796,7 +796,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/correctness/test_select_constant.out b/regression-test/data/correctness/test_select_constant.out
index d3ed51bcc7..c814de350a 100644
--- a/regression-test/data/correctness/test_select_constant.out
+++ b/regression-test/data/correctness/test_select_constant.out
@@ -2,3 +2,6 @@
 -- !select1 --
 100	test	2021-01-02
 
+-- !select --
+2010-01-02T04:03:06
+


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