diff --git a/fe/fe-core/src/main/java/org/apache/doris/analysis/CastExpr.java b/fe/fe-core/src/main/java/org/apache/doris/analysis/CastExpr.java index 6ceb8e3d84c760..cb78d785395d30 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/analysis/CastExpr.java +++ b/fe/fe-core/src/main/java/org/apache/doris/analysis/CastExpr.java @@ -314,7 +314,7 @@ public void analyze() throws AnalysisException { // it is necessary to check if it is castable before creating fn. // char type will fail in canCastTo, so for compatibility, only the cast of array type is checked here. if (type.isArrayType() || childType.isArrayType()) { - if (childType.isNull() || !Type.canCastTo(childType, type)) { + if (!Type.canCastTo(childType, type)) { throw new AnalysisException("Invalid type cast of " + getChild(0).toSql() + " from " + childType + " to " + type); } diff --git a/regression-test/data/query_p0/sql_functions/case_function/test_case_function_null.out b/regression-test/data/query_p0/sql_functions/case_function/test_case_function_null.out index de51eb0306ad09..2d2816c012eb39 100644 --- a/regression-test/data/query_p0/sql_functions/case_function/test_case_function_null.out +++ b/regression-test/data/query_p0/sql_functions/case_function/test_case_function_null.out @@ -16,3 +16,6 @@ -- !sql_case2 -- -2 +-- !sql_case3 -- +0 + diff --git a/regression-test/data/query_p0/sql_functions/cast_function/test_cast_array_functions_by_literal.out b/regression-test/data/query_p0/sql_functions/cast_function/test_cast_array_functions_by_literal.out index f2be3a70798220..8a8c513bea1366 100644 --- a/regression-test/data/query_p0/sql_functions/cast_function/test_cast_array_functions_by_literal.out +++ b/regression-test/data/query_p0/sql_functions/cast_function/test_cast_array_functions_by_literal.out @@ -23,3 +23,6 @@ -- !sql8 -- \N +-- !sql9 -- +\N + diff --git a/regression-test/suites/query_p0/sql_functions/case_function/test_case_function_null.groovy b/regression-test/suites/query_p0/sql_functions/case_function/test_case_function_null.groovy index 63e67a40f009fb..269a0bf0db87cf 100644 --- a/regression-test/suites/query_p0/sql_functions/case_function/test_case_function_null.groovy +++ b/regression-test/suites/query_p0/sql_functions/case_function/test_case_function_null.groovy @@ -228,4 +228,8 @@ suite("test_case_function_null", "query,p0") { END) FROM case_null2; """ -} \ No newline at end of file + + + qt_sql_case3 """SELECT COUNT(CASE (NOT (NOT true)) WHEN (((- 47960023)) IS NOT NULL) THEN NULL ELSE NULL END) from case_null1;""" + +} diff --git a/regression-test/suites/query_p0/sql_functions/cast_function/test_cast_array_functions_by_literal.groovy b/regression-test/suites/query_p0/sql_functions/cast_function/test_cast_array_functions_by_literal.groovy index 7f9fb604bc74cf..ae37e308e1be57 100644 --- a/regression-test/suites/query_p0/sql_functions/cast_function/test_cast_array_functions_by_literal.groovy +++ b/regression-test/suites/query_p0/sql_functions/cast_function/test_cast_array_functions_by_literal.groovy @@ -41,11 +41,7 @@ suite("test_cast_array_functions_by_literal") { // empty string is invalid array, return NULL qt_sql8 """select cast('' as array)""" - test { - sql "select cast(NULL as array)" - // check exception message contains - exception "errCode = 2," - } + qt_sql9 """select cast(NULL as array)""" test { sql "select cast(1 as array)"