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

lide pushed a commit to branch branch-1.2-lts
in repository https://gitbox.apache.org/repos/asf/doris.git


The following commit(s) were added to refs/heads/branch-1.2-lts by this push:
     new 5b49cdb5094 [branch-1.2](bug) Fix be core in If function with array 
#27646
5b49cdb5094 is described below

commit 5b49cdb5094d68998cb2cf9dedb2d248a5e2b3d4
Author: xy720 <22125576+xy...@users.noreply.github.com>
AuthorDate: Wed Nov 29 11:39:52 2023 +0800

    [branch-1.2](bug) Fix be core in If function with array #27646
---
 .../java/org/apache/doris/analysis/FunctionCallExpr.java    |  3 +++
 .../sql_functions/conditional_functions/test_if.out         | 13 +++++++++++++
 .../sql_functions/conditional_functions/test_if.groovy      |  6 +++++-
 3 files changed, 21 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 09dc26a67f2..45ae5751025 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
@@ -1530,6 +1530,9 @@ public class FunctionCallExpr extends Expr {
                             && args[ix].isDecimalV3OrContainsDecimalV3())) {
                         // Do not do this cast if types are both decimalv3 
with different precision/scale.
                         uncheckedCastChild(args[ix], i);
+                    } else if (fnName.getFunction().equalsIgnoreCase("if")
+                            && argTypes[i].isArrayType() && ((ArrayType) 
argTypes[i]).getItemType().isNull()) {
+                        uncheckedCastChild(args[ix], i);
                     }
                 }
             }
diff --git 
a/regression-test/data/query_p0/sql_functions/conditional_functions/test_if.out 
b/regression-test/data/query_p0/sql_functions/conditional_functions/test_if.out
new file mode 100644
index 00000000000..cda5d4de6c7
--- /dev/null
+++ 
b/regression-test/data/query_p0/sql_functions/conditional_functions/test_if.out
@@ -0,0 +1,13 @@
+-- This file is automatically generated. You should know what you did if you 
want to edit this
+-- !select --
+\N
+
+-- !select --
+['1970-01-01', '1970-01-01']
+
+-- !select --
+['1970-01-01', '1970-01-01']
+
+-- !select --
+[]
+
diff --git 
a/regression-test/suites/query_p0/sql_functions/conditional_functions/test_if.groovy
 
b/regression-test/suites/query_p0/sql_functions/conditional_functions/test_if.groovy
index c546e7891b8..9a99e8bbd94 100644
--- 
a/regression-test/suites/query_p0/sql_functions/conditional_functions/test_if.groovy
+++ 
b/regression-test/suites/query_p0/sql_functions/conditional_functions/test_if.groovy
@@ -16,5 +16,9 @@
 // under the License.
 
 suite("test_if") {
-    sql "select if(id=1,count,hll_empty()) from (select 1 as id, hll_hash(1) 
as count) t"
+    qt_select "select if(id=1,count,hll_empty()) from (select 1 as id, 
hll_hash(1) as count) t"
+
+    qt_select "select if(job_d is null, array(), job_d) as test from (select 
array('1970-01-01', '1970-01-01') as job_d) t"
+    qt_select "select if(job_d is null, array('1970-01-01'), job_d) as test 
from (select array('1970-01-01', '1970-01-01') as job_d) t"
+    qt_select "select if(job_d is null, job_d, array()) as test from (select 
array('1970-01-01', '1970-01-01') as job_d) t"
 }


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

Reply via email to