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

yiguolei pushed a commit to branch branch-2.0
in repository https://gitbox.apache.org/repos/asf/doris.git

commit 2680d128021bc85348e578a09994c96d4bf91d34
Author: amory <wangqian...@selectdb.com>
AuthorDate: Fri Aug 18 12:12:50 2023 +0800

    [FIX](array-func) fix array() with decimal type (#23117)
    
    if we write sql with : select array(1.0,2.0,null, null,2.0)
    here will pass arg type with uint8 to be which does not match array() func 
sign with deicmal, and make be core. so here should cast from be and make null 
tag to cast decimal type
---
 .../apache/doris/analysis/FunctionCallExpr.java    |  4 --
 .../test_array_functions_by_literal.out            | 48 ++++++++++++++++++++++
 .../test_array_functions_by_literal.groovy         | 18 ++++++++
 3 files changed, 66 insertions(+), 4 deletions(-)

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 1a3ec4149d..f83c9ce967 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
@@ -1669,10 +1669,6 @@ public class FunctionCallExpr extends Expr {
                         || fnName.getFunction().equalsIgnoreCase("hist"))
                         && children.get(0).getType().isDecimalV3() && 
args[ix].isDecimalV3()) {
                     continue;
-                } else if (fnName.getFunction().equalsIgnoreCase("array")
-                        && (children.get(0).getType().isDecimalV3() && 
args[ix].isDecimalV3()
-                        || children.get(0).getType().isDatetimeV2() && 
args[ix].isDatetimeV2())) {
-                    continue;
                 } else if ((fnName.getFunction().equalsIgnoreCase("array_min") 
|| fnName.getFunction()
                         .equalsIgnoreCase("array_max") || 
fnName.getFunction().equalsIgnoreCase("element_at"))
                         && ((
diff --git 
a/regression-test/data/query_p0/sql_functions/array_functions/test_array_functions_by_literal.out
 
b/regression-test/data/query_p0/sql_functions/array_functions/test_array_functions_by_literal.out
index 63103fa437..8e69544962 100644
--- 
a/regression-test/data/query_p0/sql_functions/array_functions/test_array_functions_by_literal.out
+++ 
b/regression-test/data/query_p0/sql_functions/array_functions/test_array_functions_by_literal.out
@@ -2,6 +2,54 @@
 -- !sql --
 [1, 1, 2, 2, 2, 2]
 
+-- !sql_1 --
+[1.0, 2.0, NULL, NULL, 2.0]
+
+-- !sql_1 --
+["a", "2.0", NULL, NULL, "2.0"]
+
+-- !sql_1 --
+[1, 2, NULL, NULL, 2]
+
+-- !sql_2 --
+[NULL, NULL, 1.0, 2.0, 2.0]
+
+-- !sql_3 --
+1.0
+
+-- !sql_4 --
+2.0
+
+-- !sql_5 --
+1.6
+
+-- !sql_6 --
+5.0
+
+-- !sql_7 --
+4.0
+
+-- !sql_8 --
+[1.0, 2.0, NULL]
+
+-- !sql_9 --
+[NULL, 1.0, 2.0]
+
+-- !sql_10 --
+[]
+
+-- !sql_11 --
+[1.0, 2.0, NULL]
+
+-- !sql_14 --
+[2.0, NULL, NULL, 2.0]
+
+-- !sql_15 --
+[1.0, 2.0, NULL, NULL]
+
+-- !sql_16 --
+[1.0, 2.0, NULL, NULL, 2.0, 1.0, 2.0, NULL, NULL, 2.0]
+
 -- !sql --
 true
 
diff --git 
a/regression-test/suites/query_p0/sql_functions/array_functions/test_array_functions_by_literal.groovy
 
b/regression-test/suites/query_p0/sql_functions/array_functions/test_array_functions_by_literal.groovy
index d969312431..d541d24470 100644
--- 
a/regression-test/suites/query_p0/sql_functions/array_functions/test_array_functions_by_literal.groovy
+++ 
b/regression-test/suites/query_p0/sql_functions/array_functions/test_array_functions_by_literal.groovy
@@ -19,6 +19,24 @@ suite("test_array_functions_by_literal") {
     // array_nested function
     qt_sql "select a from (select array(1, 1, 2, 2, 2, 2) as a) t"
 
+    // array with decimal and other types
+    qt_sql_1 """select array(1.0,2.0,null, null,2.0);"""
+    qt_sql_1 """select array('a',2.0,null, null,2.0);"""
+    qt_sql_1 """select array(1,2.0,null, null,2.0);"""
+    qt_sql_2 """select array_sort(array(1.0,2.0,null, null,2.0));"""
+    qt_sql_3 """select array_min(array(1.0,2.0,null, null,2.0));"""
+    qt_sql_4 """select array_max(array(1.0,2.0,null, null,2.0));"""
+    qt_sql_5 """select array_avg(array(1.0,2.0,null, null,2.0));"""
+    qt_sql_6 """select array_sum(array(1.0,2.0,null, null,2.0));"""
+    qt_sql_7 """select array_product(array(1.0,2.0,null, null,2.0));"""
+    qt_sql_8 """select array_distinct(array(1.0,2.0,null, null,2.0));"""
+    qt_sql_9 """select array_intersect(array(1.0,2.0,null, null,2.0), 
array(1.0,2.0,null, null,2.0));"""
+    qt_sql_10 """select array_except(array(1.0,2.0,null, null,2.0), 
array(1.0,2.0,null, null,2.0));"""
+    qt_sql_11 """select array_union(array(1.0,2.0,null, null,2.0), 
array(1.0,2.0,null, null,2.0));"""
+    qt_sql_14 """select array_popfront(array(1.0,2.0,null, null,2.0));"""
+    qt_sql_15 """select array_popback(array(1.0,2.0,null, null,2.0));"""
+    qt_sql_16 """select array_concat(array(1.0,2.0,null, null,2.0), 
array(1.0,2.0,null, null,2.0));"""
+
 
     // array_contains function
     qt_sql "select array_contains([1,2,3], 1)"


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

Reply via email to