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 7fbbfbadf4..1a3ec4149d 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 @@ -1411,20 +1411,22 @@ public class FunctionCallExpr extends Expr { } else if (fnName.getFunction().equalsIgnoreCase("ifnull")) { Type[] childTypes = collectChildReturnTypes(); Type assignmentCompatibleType = ScalarType.getAssignmentCompatibleType(childTypes[0], childTypes[1], true); - if (assignmentCompatibleType.isDecimalV3()) { - if (assignmentCompatibleType.isDecimalV3() && !childTypes[0].equals(assignmentCompatibleType)) { - uncheckedCastChild(assignmentCompatibleType, 0); + if (assignmentCompatibleType != Type.INVALID) { + if (assignmentCompatibleType.isDecimalV3()) { + if (assignmentCompatibleType.isDecimalV3() && !childTypes[0].equals(assignmentCompatibleType)) { + uncheckedCastChild(assignmentCompatibleType, 0); + } + if (assignmentCompatibleType.isDecimalV3() && !childTypes[1].equals(assignmentCompatibleType)) { + uncheckedCastChild(assignmentCompatibleType, 1); + } } - if (assignmentCompatibleType.isDecimalV3() && !childTypes[1].equals(assignmentCompatibleType)) { - uncheckedCastChild(assignmentCompatibleType, 1); - } - } - childTypes[0] = assignmentCompatibleType; - childTypes[1] = assignmentCompatibleType; + childTypes[0] = assignmentCompatibleType; + childTypes[1] = assignmentCompatibleType; - if (childTypes[1].isDecimalV3() && childTypes[0].isDecimalV3()) { - argTypes[1] = assignmentCompatibleType; - argTypes[0] = assignmentCompatibleType; + if (childTypes[1].isDecimalV3() && childTypes[0].isDecimalV3()) { + argTypes[1] = assignmentCompatibleType; + argTypes[0] = assignmentCompatibleType; + } } fn = getBuiltinFunction(fnName.getFunction(), childTypes, Function.CompareMode.IS_NONSTRICT_SUPERTYPE_OF); diff --git a/regression-test/data/correctness_p0/test_select_constant.out b/regression-test/data/correctness_p0/test_select_constant.out index cb391ffb12..33c56d3a22 100644 --- a/regression-test/data/correctness_p0/test_select_constant.out +++ b/regression-test/data/correctness_p0/test_select_constant.out @@ -5,3 +5,6 @@ -- !select_geo1 -- POINT (123.123456789 89.123456789) +-- !select2 -- +20230101 + diff --git a/regression-test/suites/correctness_p0/test_select_constant.groovy b/regression-test/suites/correctness_p0/test_select_constant.groovy index 6015e19576..38c1c2efdb 100644 --- a/regression-test/suites/correctness_p0/test_select_constant.groovy +++ b/regression-test/suites/correctness_p0/test_select_constant.groovy @@ -18,4 +18,7 @@ suite("test_select_constant") { qt_select1 'select 100, "test", date("2021-01-02");' qt_select_geo1 'SELECT ST_AsText(ST_Point(123.12345678901234567890,89.1234567890));' + + sql "set enable_nereids_planner=false;" + qt_select2 """select ifnull(cast('2023-01-01' as DATE) ,0);""" }