You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by kx...@apache.org on 2023/06/06 15:15:20 UTC

[doris] 18/36: [fix](nereids) change defaultConcreteType function's return value for decimal (#20380)

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

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

commit b5027ef1bab2e86d3a0e1d2cd20ecd82235eef78
Author: starocean999 <40...@users.noreply.github.com>
AuthorDate: Mon Jun 5 10:50:07 2023 +0800

    [fix](nereids) change defaultConcreteType function's return value for decimal (#20380)
    
    1. add default decimalv2 and decimalv3 for NullType
    2. change defaultConcreteType of decimalv3 to this
---
 .../trees/expressions/functions/scalar/Nvl.java    |  2 +-
 .../apache/doris/nereids/types/DecimalV2Type.java  |  3 ++-
 .../apache/doris/nereids/types/DecimalV3Type.java  |  3 ++-
 .../conditional_functions/test_coalesce.out        | 24 +++++++++++-----------
 .../conditional_functions/test_nullif.out          |  8 ++++----
 5 files changed, 21 insertions(+), 19 deletions(-)

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 cf553199fe..5e5e8736b6 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
@@ -58,8 +58,8 @@ public class Nvl extends ScalarFunction
             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(FloatType.INSTANCE).args(FloatType.INSTANCE, FloatType.INSTANCE),
             FunctionSignature.ret(DateType.INSTANCE).args(DateType.INSTANCE, DateType.INSTANCE),
             FunctionSignature.ret(DateTimeType.INSTANCE).args(DateTimeType.INSTANCE, DateTimeType.INSTANCE),
             FunctionSignature.ret(DateTimeType.INSTANCE).args(DateType.INSTANCE, DateTimeType.INSTANCE),
diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/types/DecimalV2Type.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/types/DecimalV2Type.java
index bbee1c1ecc..d599fbe0c3 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/nereids/types/DecimalV2Type.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/types/DecimalV2Type.java
@@ -62,6 +62,7 @@ public class DecimalV2Type extends FractionalType {
             .put(DoubleType.INSTANCE, DOUBLE_DECIMAL)
             .put(TimeType.INSTANCE, DOUBLE_DECIMAL)
             .put(TimeV2Type.INSTANCE, DOUBLE_DECIMAL)
+            .put(NullType.INSTANCE, BOOLEAN_DECIMAL)
             .build();
 
     private final int precision;
@@ -137,7 +138,7 @@ public class DecimalV2Type extends FractionalType {
 
     @Override
     public DataType defaultConcreteType() {
-        return SYSTEM_DEFAULT;
+        return this;
     }
 
     @Override
diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/types/DecimalV3Type.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/types/DecimalV3Type.java
index 259da3ea90..4c78513b50 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/nereids/types/DecimalV3Type.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/types/DecimalV3Type.java
@@ -60,6 +60,7 @@ public class DecimalV3Type extends FractionalType {
             .put(LargeIntType.INSTANCE, LARGEINT_DECIMAL)
             .put(FloatType.INSTANCE, FLOAT_DECIMAL)
             .put(DoubleType.INSTANCE, DOUBLE_DECIMAL)
+            .put(NullType.INSTANCE, BOOLEAN_DECIMAL)
             .build();
 
     protected final int precision;
@@ -146,7 +147,7 @@ public class DecimalV3Type extends FractionalType {
 
     @Override
     public DataType defaultConcreteType() {
-        return SYSTEM_DEFAULT;
+        return this;
     }
 
     @Override
diff --git a/regression-test/data/nereids_p0/sql_functions/conditional_functions/test_coalesce.out b/regression-test/data/nereids_p0/sql_functions/conditional_functions/test_coalesce.out
index 82dbea9a25..f25ac04c28 100644
--- a/regression-test/data/nereids_p0/sql_functions/conditional_functions/test_coalesce.out
+++ b/regression-test/data/nereids_p0/sql_functions/conditional_functions/test_coalesce.out
@@ -326,11 +326,11 @@
 -- !coalesce3 --
 \N	\N
 1	123.123
-2	1243.5
-3	24453.324
-4	243243.33
+2	1243.500
+3	24453.325
+4	243243.325
 5	243.325
-6	604587.0
+6	604587.000
 7	3.141
 8	-0.123
 9	-654.654
@@ -338,17 +338,17 @@
 11	0.666
 12	243.325
 13	100.001
-14	0.0
-15	0.0
+14	0.000
+15	0.000
 
 -- !coalesce4 --
 \N	\N
 1	123.123
-2	1243.5
-3	24453.324
-4	243243.33
+2	1243.500
+3	24453.325
+4	243243.325
 5	243.325
-6	604587.0
+6	604587.000
 7	3.141
 8	-0.123
 9	-654.654
@@ -356,8 +356,8 @@
 11	0.666
 12	243.325
 13	100.001
-14	0.0
-15	0.0
+14	0.000
+15	0.000
 
 -- !coalesce1 --
 \N	\N
diff --git a/regression-test/data/nereids_p0/sql_functions/conditional_functions/test_nullif.out b/regression-test/data/nereids_p0/sql_functions/conditional_functions/test_nullif.out
index dfda4676d3..f0746996f0 100644
--- a/regression-test/data/nereids_p0/sql_functions/conditional_functions/test_nullif.out
+++ b/regression-test/data/nereids_p0/sql_functions/conditional_functions/test_nullif.out
@@ -490,13 +490,13 @@ null	NULL	null	NULLL
 
 -- !if_nullif23 --
 123.123
-1243.5
-24453.324
+1243.500
+24453.325
 
 -- !if_nullif24 --
 123.123
-1243.5
-24453.324
+1243.500
+24453.325
 
 -- !if_nullif23 --
 false


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