diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Coalesce.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Coalesce.java index f1d122d0179d4f..2ed864ba9a0c30 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Coalesce.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Coalesce.java @@ -36,6 +36,8 @@ import org.apache.doris.nereids.types.LargeIntType; import org.apache.doris.nereids.types.SmallIntType; import org.apache.doris.nereids.types.StringType; +import org.apache.doris.nereids.types.TimeType; +import org.apache.doris.nereids.types.TimeV2Type; import org.apache.doris.nereids.types.TinyIntType; import org.apache.doris.nereids.types.VarcharType; import org.apache.doris.nereids.util.ExpressionUtils; @@ -64,6 +66,8 @@ public class Coalesce extends ScalarFunction FunctionSignature.ret(DateTimeType.INSTANCE).varArgs(DateTimeType.INSTANCE), FunctionSignature.ret(DateV2Type.INSTANCE).varArgs(DateV2Type.INSTANCE), FunctionSignature.ret(DateType.INSTANCE).varArgs(DateType.INSTANCE), + FunctionSignature.ret(TimeType.INSTANCE).varArgs(TimeType.INSTANCE), + FunctionSignature.ret(TimeV2Type.INSTANCE).varArgs(TimeV2Type.INSTANCE), FunctionSignature.ret(DecimalV3Type.WILDCARD).varArgs(DecimalV3Type.WILDCARD), FunctionSignature.ret(DecimalV2Type.SYSTEM_DEFAULT).varArgs(DecimalV2Type.SYSTEM_DEFAULT), FunctionSignature.ret(BitmapType.INSTANCE).varArgs(BitmapType.INSTANCE), diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/If.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/If.java index 4b6f62f6bc8bc6..655649822c833a 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/If.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/If.java @@ -43,6 +43,8 @@ import org.apache.doris.nereids.types.NullType; import org.apache.doris.nereids.types.SmallIntType; import org.apache.doris.nereids.types.StringType; +import org.apache.doris.nereids.types.TimeType; +import org.apache.doris.nereids.types.TimeV2Type; import org.apache.doris.nereids.types.TinyIntType; import org.apache.doris.nereids.types.VarcharType; import org.apache.doris.nereids.types.coercion.AnyDataType; @@ -84,7 +86,12 @@ public class If extends ScalarFunction .args(BooleanType.INSTANCE, DoubleType.INSTANCE, DoubleType.INSTANCE), FunctionSignature.ret(DateTimeType.INSTANCE) .args(BooleanType.INSTANCE, DateTimeType.INSTANCE, DateTimeType.INSTANCE), - FunctionSignature.ret(DateType.INSTANCE).args(BooleanType.INSTANCE, DateType.INSTANCE, DateType.INSTANCE), + FunctionSignature.ret(DateType.INSTANCE).args(BooleanType.INSTANCE, DateType.INSTANCE, + DateType.INSTANCE), + FunctionSignature.ret(TimeType.INSTANCE).args(BooleanType.INSTANCE, TimeType.INSTANCE, + TimeType.INSTANCE), + FunctionSignature.ret(TimeV2Type.INSTANCE).args(BooleanType.INSTANCE, TimeV2Type.INSTANCE, + TimeV2Type.INSTANCE), FunctionSignature.ret(DecimalV3Type.WILDCARD) .args(BooleanType.INSTANCE, DecimalV3Type.WILDCARD, DecimalV3Type.WILDCARD), FunctionSignature.ret(DecimalV2Type.SYSTEM_DEFAULT) diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/NullIf.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/NullIf.java index 447e60a752fc64..fe6164dc085252 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/NullIf.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/NullIf.java @@ -37,6 +37,8 @@ import org.apache.doris.nereids.types.LargeIntType; import org.apache.doris.nereids.types.SmallIntType; import org.apache.doris.nereids.types.StringType; +import org.apache.doris.nereids.types.TimeType; +import org.apache.doris.nereids.types.TimeV2Type; import org.apache.doris.nereids.types.TinyIntType; import org.apache.doris.nereids.types.VarcharType; @@ -65,6 +67,8 @@ public class NullIf extends ScalarFunction FunctionSignature.ret(DateTimeV2Type.SYSTEM_DEFAULT) .args(DateTimeV2Type.SYSTEM_DEFAULT, DateTimeV2Type.SYSTEM_DEFAULT), FunctionSignature.ret(DateV2Type.INSTANCE).args(DateV2Type.INSTANCE, DateV2Type.INSTANCE), + FunctionSignature.ret(TimeType.INSTANCE).args(TimeType.INSTANCE, TimeType.INSTANCE), + FunctionSignature.ret(TimeV2Type.INSTANCE).args(TimeV2Type.INSTANCE, TimeV2Type.INSTANCE), FunctionSignature.ret(DecimalV2Type.SYSTEM_DEFAULT) .args(DecimalV2Type.SYSTEM_DEFAULT, DecimalV2Type.SYSTEM_DEFAULT), FunctionSignature.ret(DecimalV3Type.WILDCARD) diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Nvl.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Nvl.java index e3d0335cbc3345..658e05f1148345 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Nvl.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Nvl.java @@ -36,6 +36,8 @@ import org.apache.doris.nereids.types.LargeIntType; import org.apache.doris.nereids.types.SmallIntType; import org.apache.doris.nereids.types.StringType; +import org.apache.doris.nereids.types.TimeType; +import org.apache.doris.nereids.types.TimeV2Type; import org.apache.doris.nereids.types.TinyIntType; import org.apache.doris.nereids.types.VarcharType; @@ -65,7 +67,11 @@ public class Nvl extends ScalarFunction FunctionSignature.ret(DateTimeV2Type.SYSTEM_DEFAULT) .args(DateTimeV2Type.SYSTEM_DEFAULT, DateTimeV2Type.SYSTEM_DEFAULT), FunctionSignature.ret(DateV2Type.INSTANCE) - .args(DateV2Type.INSTANCE, DateV2Type.INSTANCE), + .args(DateV2Type.INSTANCE, DateV2Type.INSTANCE), + FunctionSignature.ret(TimeType.INSTANCE) + .args(TimeType.INSTANCE, TimeType.INSTANCE), + FunctionSignature.ret(TimeV2Type.INSTANCE) + .args(TimeV2Type.INSTANCE, TimeV2Type.INSTANCE), FunctionSignature.ret(BitmapType.INSTANCE).args(BitmapType.INSTANCE, BitmapType.INSTANCE), FunctionSignature.ret(VarcharType.SYSTEM_DEFAULT) .args(VarcharType.SYSTEM_DEFAULT, VarcharType.SYSTEM_DEFAULT), diff --git a/regression-test/data/correctness_p0/test_case_when_decimal.out b/regression-test/data/correctness_p0/test_case_when_decimal.out index 1a888306ed3048..ba416b026bf7c2 100644 --- a/regression-test/data/correctness_p0/test_case_when_decimal.out +++ b/regression-test/data/correctness_p0/test_case_when_decimal.out @@ -8,3 +8,9 @@ -- !sql3 -- 4.41 +-- !sql4 -- +00:01:23 00:01:23 00:01:23 00:01:23 + +-- !sql5 -- +00:01:23 00:01:23 00:01:23 00:01:23 + diff --git a/regression-test/suites/correctness_p0/test_case_when_decimal.groovy b/regression-test/suites/correctness_p0/test_case_when_decimal.groovy index baf7f52690e916..d9afe72624e233 100644 --- a/regression-test/suites/correctness_p0/test_case_when_decimal.groovy +++ b/regression-test/suites/correctness_p0/test_case_when_decimal.groovy @@ -97,4 +97,13 @@ suite("test_case_when_decimal") { sql """ DROP TABLE IF EXISTS `decimal_to_double_table1`; """ sql """ DROP TABLE IF EXISTS `decimal_to_double_table2`; """ + + + qt_sql4 """ + select ifnull(cast(123 as time) , cast(300 as time)) , coalesce(cast(123 as time) , cast(300 as time)) , if(true ,cast(123 as time) , cast(300 as time)) , nullif(cast(123 as time) , cast(300 as time)); + """ + + qt_sql5 """ + select ifnull(cast(123 as time) , cast(300 as time)) , coalesce(cast(123 as time) , cast(300 as time)) , if(true ,cast(123 as time) , cast(300 as time)) , nullif(cast(123 as time) , cast(300 as time)); + """ }