This is an automated email from the ASF dual-hosted git repository.
yiguolei pushed a commit to branch branch-2.1
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/branch-2.1 by this push:
new 6457a9a642e [fix](Nereids) system default decimalv3 scale should be 9
(#32754)
6457a9a642e is described below
commit 6457a9a642e42bfc89d423bd1a42e36cbfe13d74
Author: morrySnow <[email protected]>
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: [email protected]
For additional commands, e-mail: [email protected]