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 ba541c59303 [fix](Nereids) system default decimalv3 scale should be 9 
(#32754)
ba541c59303 is described below

commit ba541c5930382a18f54a4961a1fd4ceb4ac4beff
Author: morrySnow <101034200+morrys...@users.noreply.github.com>
AuthorDate: Tue Mar 26 09:50:11 2024 +0800

    [fix](Nereids) system default decimalv3 scale should be 9 (#32754)
    
    select round('1.1234', 2) should return 1.12, not 1
---
 .../main/java/org/apache/doris/nereids/types/DecimalV3Type.java   | 2 +-
 .../nereids/rules/expression/SimplifyArithmeticRuleTest.java      | 2 +-
 .../java/org/apache/doris/nereids/util/TypeCoercionUtilsTest.java | 8 ++++----
 3 files changed, 6 insertions(+), 6 deletions(-)

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 f87f95db4a3..aaef3775b34 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
@@ -42,7 +42,7 @@ public class DecimalV3Type extends FractionalType {
     public static final int MAX_DECIMAL256_PRECISION = 76;
 
     public static final DecimalV3Type WILDCARD = new DecimalV3Type(-1, -1);
-    public static final DecimalV3Type SYSTEM_DEFAULT = new 
DecimalV3Type(MAX_DECIMAL128_PRECISION, DEFAULT_SCALE);
+    public static final DecimalV3Type SYSTEM_DEFAULT = new 
DecimalV3Type(MAX_DECIMAL128_PRECISION, 9);
     public static final DecimalV3Type CATALOG_DEFAULT = new 
DecimalV3Type(MAX_DECIMAL32_PRECISION, DEFAULT_SCALE);
 
     private static final DecimalV3Type BOOLEAN_DECIMAL = new DecimalV3Type(1, 
0);
diff --git 
a/fe/fe-core/src/test/java/org/apache/doris/nereids/rules/expression/SimplifyArithmeticRuleTest.java
 
b/fe/fe-core/src/test/java/org/apache/doris/nereids/rules/expression/SimplifyArithmeticRuleTest.java
index 4ea50bf1f88..174592270dd 100644
--- 
a/fe/fe-core/src/test/java/org/apache/doris/nereids/rules/expression/SimplifyArithmeticRuleTest.java
+++ 
b/fe/fe-core/src/test/java/org/apache/doris/nereids/rules/expression/SimplifyArithmeticRuleTest.java
@@ -87,7 +87,7 @@ class SimplifyArithmeticRuleTest extends 
ExpressionRewriteTestHelper {
         assertRewriteAfterTypeCoercion("(-IA / 2) / ((-IB - 1) / (3 + (IC * 
4)))", "(((cast((0 - IA) as DOUBLE) / cast(((0 - IB) - 1) as DOUBLE)) * cast((3 
+ (IC * 4)) as DOUBLE)) / cast(2 as DOUBLE))");
 
         // unsupported decimal
-        assertRewriteAfterTypeCoercion("-2 - MA - ((1 - IB) - (3 + IC))", 
"((cast(-2 as DECIMALV3(38, 0)) - MA) - cast(((1 - IB) - (3 + IC)) as 
DECIMALV3(38, 0)))");
+        assertRewriteAfterTypeCoercion("-2 - MA - ((1 - IB) - (3 + IC))", 
"((cast(-2 as DECIMALV3(38, 9)) - MA) - cast(((1 - IB) - (3 + IC)) as 
DECIMALV3(38, 9)))");
         assertRewriteAfterTypeCoercion("-IA / 2.0 * ((-IB - 1) - (3 + (IC + 
4)))", "((cast((0 - IA) as DECIMALV3(25, 5)) / 2.0) * cast((((0 - IB) - 1) - (3 
+ (IC + 4))) as DECIMALV3(20, 0)))");
     }
 
diff --git 
a/fe/fe-core/src/test/java/org/apache/doris/nereids/util/TypeCoercionUtilsTest.java
 
b/fe/fe-core/src/test/java/org/apache/doris/nereids/util/TypeCoercionUtilsTest.java
index a30d67d4d31..d9a2946ba88 100644
--- 
a/fe/fe-core/src/test/java/org/apache/doris/nereids/util/TypeCoercionUtilsTest.java
+++ 
b/fe/fe-core/src/test/java/org/apache/doris/nereids/util/TypeCoercionUtilsTest.java
@@ -284,7 +284,7 @@ public class TypeCoercionUtilsTest {
         testFindCommonPrimitiveTypeForCaseWhen(LargeIntType.INSTANCE, 
LargeIntType.INSTANCE, BigIntType.INSTANCE);
         testFindCommonPrimitiveTypeForCaseWhen(LargeIntType.INSTANCE, 
LargeIntType.INSTANCE, LargeIntType.INSTANCE);
         testFindCommonPrimitiveTypeForCaseWhen(DecimalV2Type.SYSTEM_DEFAULT, 
LargeIntType.INSTANCE, DecimalV2Type.SYSTEM_DEFAULT);
-        testFindCommonPrimitiveTypeForCaseWhen(DecimalV3Type.SYSTEM_DEFAULT, 
LargeIntType.INSTANCE, DecimalV3Type.SYSTEM_DEFAULT);
+        
testFindCommonPrimitiveTypeForCaseWhen(DecimalV3Type.createDecimalV3Type(38), 
LargeIntType.INSTANCE, DecimalV3Type.createDecimalV3Type(38));
         testFindCommonPrimitiveTypeForCaseWhen(DoubleType.INSTANCE, 
LargeIntType.INSTANCE, FloatType.INSTANCE);
         testFindCommonPrimitiveTypeForCaseWhen(DoubleType.INSTANCE, 
LargeIntType.INSTANCE, DoubleType.INSTANCE);
         testFindCommonPrimitiveTypeForCaseWhen(StringType.INSTANCE, 
LargeIntType.INSTANCE, CharType.SYSTEM_DEFAULT);
@@ -308,7 +308,7 @@ public class TypeCoercionUtilsTest {
         testFindCommonPrimitiveTypeForCaseWhen(DecimalV2Type.SYSTEM_DEFAULT, 
DecimalV2Type.SYSTEM_DEFAULT, LargeIntType.INSTANCE);
         testFindCommonPrimitiveTypeForCaseWhen(DecimalV2Type.SYSTEM_DEFAULT, 
DecimalV2Type.SYSTEM_DEFAULT,
                 DecimalV2Type.SYSTEM_DEFAULT);
-        testFindCommonPrimitiveTypeForCaseWhen(DoubleType.INSTANCE, 
DecimalV2Type.SYSTEM_DEFAULT,
+        testFindCommonPrimitiveTypeForCaseWhen(DecimalV3Type.SYSTEM_DEFAULT, 
DecimalV2Type.SYSTEM_DEFAULT,
                 DecimalV3Type.SYSTEM_DEFAULT);
         testFindCommonPrimitiveTypeForCaseWhen(DoubleType.INSTANCE, 
DecimalV2Type.SYSTEM_DEFAULT, FloatType.INSTANCE);
         testFindCommonPrimitiveTypeForCaseWhen(DoubleType.INSTANCE, 
DecimalV2Type.SYSTEM_DEFAULT, DoubleType.INSTANCE);
@@ -331,10 +331,10 @@ public class TypeCoercionUtilsTest {
         testFindCommonPrimitiveTypeForCaseWhen(DecimalV3Type.SYSTEM_DEFAULT, 
DecimalV3Type.SYSTEM_DEFAULT, SmallIntType.INSTANCE);
         testFindCommonPrimitiveTypeForCaseWhen(DecimalV3Type.SYSTEM_DEFAULT, 
DecimalV3Type.SYSTEM_DEFAULT, IntegerType.INSTANCE);
         testFindCommonPrimitiveTypeForCaseWhen(DecimalV3Type.SYSTEM_DEFAULT, 
DecimalV3Type.SYSTEM_DEFAULT, BigIntType.INSTANCE);
-        testFindCommonPrimitiveTypeForCaseWhen(DecimalV3Type.SYSTEM_DEFAULT, 
DecimalV3Type.SYSTEM_DEFAULT, LargeIntType.INSTANCE);
+        
testFindCommonPrimitiveTypeForCaseWhen(DecimalV3Type.createDecimalV3Type(38), 
DecimalV3Type.createDecimalV3Type(38), LargeIntType.INSTANCE);
         testFindCommonPrimitiveTypeForCaseWhen(DecimalV3Type.SYSTEM_DEFAULT, 
DecimalV3Type.SYSTEM_DEFAULT,
                 DecimalV2Type.createDecimalV2Type(27, 0));
-        testFindCommonPrimitiveTypeForCaseWhen(DoubleType.INSTANCE, 
DecimalV3Type.SYSTEM_DEFAULT,
+        testFindCommonPrimitiveTypeForCaseWhen(DecimalV3Type.SYSTEM_DEFAULT, 
DecimalV3Type.SYSTEM_DEFAULT,
                 DecimalV2Type.SYSTEM_DEFAULT);
         testFindCommonPrimitiveTypeForCaseWhen(DecimalV3Type.SYSTEM_DEFAULT, 
DecimalV3Type.SYSTEM_DEFAULT,
                 DecimalV3Type.SYSTEM_DEFAULT);


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

Reply via email to