This is an automated email from the ASF dual-hosted git repository.
morrysnow pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/master by this push:
new aaf7a96ee6f [fix](nullif) revert nullif signature change by #38497
(#39342)
aaf7a96ee6f is described below
commit aaf7a96ee6fc6c57791f21832f76cb00e51ee188
Author: morrySnow <[email protected]>
AuthorDate: Wed Aug 14 23:12:04 2024 +0800
[fix](nullif) revert nullif signature change by #38497 (#39342)
#38497 let second arg follow first arg's type.
but the correct way is let second arg convert to a new type get from
processing like 1st = 2nd. and then compare this two arg with the 2nd
arg type when execution.
this pr revert nullif signature. and will let nullif work as expected in
future PR.
---
.../trees/expressions/functions/scalar/NullIf.java | 39 ++++++++++++++++++++--
.../data/nereids_function_p0/type_coercion.out | 3 ++
.../nereids_function_p0/type_coercion.groovy | 1 +
3 files changed, 40 insertions(+), 3 deletions(-)
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 d8985519a1b..447e60a752f 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
@@ -23,8 +23,22 @@ import
org.apache.doris.nereids.trees.expressions.functions.AlwaysNullable;
import
org.apache.doris.nereids.trees.expressions.functions.ExplicitlyCastableSignature;
import org.apache.doris.nereids.trees.expressions.shape.BinaryExpression;
import org.apache.doris.nereids.trees.expressions.visitor.ExpressionVisitor;
-import org.apache.doris.nereids.types.coercion.AnyDataType;
-import org.apache.doris.nereids.types.coercion.FollowToAnyDataType;
+import org.apache.doris.nereids.types.BigIntType;
+import org.apache.doris.nereids.types.BooleanType;
+import org.apache.doris.nereids.types.DateTimeType;
+import org.apache.doris.nereids.types.DateTimeV2Type;
+import org.apache.doris.nereids.types.DateType;
+import org.apache.doris.nereids.types.DateV2Type;
+import org.apache.doris.nereids.types.DecimalV2Type;
+import org.apache.doris.nereids.types.DecimalV3Type;
+import org.apache.doris.nereids.types.DoubleType;
+import org.apache.doris.nereids.types.FloatType;
+import org.apache.doris.nereids.types.IntegerType;
+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.TinyIntType;
+import org.apache.doris.nereids.types.VarcharType;
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableList;
@@ -38,7 +52,26 @@ public class NullIf extends ScalarFunction
implements BinaryExpression, ExplicitlyCastableSignature,
AlwaysNullable {
public static final List<FunctionSignature> SIGNATURES = ImmutableList.of(
- FunctionSignature.retArgType(0).args(new AnyDataType(0), new
FollowToAnyDataType(0))
+
FunctionSignature.ret(BooleanType.INSTANCE).args(BooleanType.INSTANCE,
BooleanType.INSTANCE),
+
FunctionSignature.ret(TinyIntType.INSTANCE).args(TinyIntType.INSTANCE,
TinyIntType.INSTANCE),
+
FunctionSignature.ret(SmallIntType.INSTANCE).args(SmallIntType.INSTANCE,
SmallIntType.INSTANCE),
+
FunctionSignature.ret(IntegerType.INSTANCE).args(IntegerType.INSTANCE,
IntegerType.INSTANCE),
+
FunctionSignature.ret(BigIntType.INSTANCE).args(BigIntType.INSTANCE,
BigIntType.INSTANCE),
+
FunctionSignature.ret(LargeIntType.INSTANCE).args(LargeIntType.INSTANCE,
LargeIntType.INSTANCE),
+ FunctionSignature.ret(FloatType.INSTANCE).args(FloatType.INSTANCE,
FloatType.INSTANCE),
+
FunctionSignature.ret(DoubleType.INSTANCE).args(DoubleType.INSTANCE,
DoubleType.INSTANCE),
+
FunctionSignature.ret(DateTimeType.INSTANCE).args(DateTimeType.INSTANCE,
DateTimeType.INSTANCE),
+ FunctionSignature.ret(DateType.INSTANCE).args(DateType.INSTANCE,
DateType.INSTANCE),
+ FunctionSignature.ret(DateTimeV2Type.SYSTEM_DEFAULT)
+ .args(DateTimeV2Type.SYSTEM_DEFAULT,
DateTimeV2Type.SYSTEM_DEFAULT),
+
FunctionSignature.ret(DateV2Type.INSTANCE).args(DateV2Type.INSTANCE,
DateV2Type.INSTANCE),
+ FunctionSignature.ret(DecimalV2Type.SYSTEM_DEFAULT)
+ .args(DecimalV2Type.SYSTEM_DEFAULT,
DecimalV2Type.SYSTEM_DEFAULT),
+ FunctionSignature.ret(DecimalV3Type.WILDCARD)
+ .args(DecimalV3Type.WILDCARD, DecimalV3Type.WILDCARD),
+ FunctionSignature.ret(VarcharType.SYSTEM_DEFAULT)
+ .args(VarcharType.SYSTEM_DEFAULT,
VarcharType.SYSTEM_DEFAULT),
+
FunctionSignature.ret(StringType.INSTANCE).args(StringType.INSTANCE,
StringType.INSTANCE)
);
/**
diff --git a/regression-test/data/nereids_function_p0/type_coercion.out
b/regression-test/data/nereids_function_p0/type_coercion.out
index 54fddd1e5b6..b600040e8f6 100644
--- a/regression-test/data/nereids_function_p0/type_coercion.out
+++ b/regression-test/data/nereids_function_p0/type_coercion.out
@@ -32,3 +32,6 @@
-- !pmod --
0.0
+-- !nullif --
+13
+
diff --git a/regression-test/suites/nereids_function_p0/type_coercion.groovy
b/regression-test/suites/nereids_function_p0/type_coercion.groovy
index 8c5dcb8134e..57b63030adb 100644
--- a/regression-test/suites/nereids_function_p0/type_coercion.groovy
+++ b/regression-test/suites/nereids_function_p0/type_coercion.groovy
@@ -27,4 +27,5 @@ suite("function_type_coercion") {
qt_array_enumerate_uniq """select
array_enumerate_uniq([1,1,1],['1','1','1.0'])"""
qt_array_cum_sum """select array_cum_sum(array('1', '2', '3000'))"""
qt_pmod """select pmod(2, '1.0')"""
+ qt_nullif """SELECT nullif(13, -4851)"""
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]