This is an automated email from the ASF dual-hosted git repository. lide pushed a commit to branch branch-1.2-lts in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/branch-1.2-lts by this push: new 655076237f1 [Bug](DECIMAL) Fix bug for arithmatic expr DECIMALV2 / DECIMALV3 (#18723) (#32264) 655076237f1 is described below commit 655076237f11ee0b8a53ae371bb069071404f9eb Author: camby <camby...@tencent.com> AuthorDate: Thu Mar 14 21:52:20 2024 +0800 [Bug](DECIMAL) Fix bug for arithmatic expr DECIMALV2 / DECIMALV3 (#18723) (#32264) Co-authored-by: Gabriel <gabrielleeb...@gmail.com> --- .../org/apache/doris/analysis/ArithmeticExpr.java | 2 +- .../decimalv3/test_arithmetic_expressions.out | 6 ++++++ .../decimalv3/test_arithmetic_expressions.groovy | 22 ++++++++++++++++++++++ 3 files changed, 29 insertions(+), 1 deletion(-) diff --git a/fe/fe-core/src/main/java/org/apache/doris/analysis/ArithmeticExpr.java b/fe/fe-core/src/main/java/org/apache/doris/analysis/ArithmeticExpr.java index c9bbb3c1cd5..56e4cb466de 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/analysis/ArithmeticExpr.java +++ b/fe/fe-core/src/main/java/org/apache/doris/analysis/ArithmeticExpr.java @@ -557,7 +557,7 @@ public class ArithmeticExpr extends Expr { if (((ScalarType) type).getScalarScale() != ((ScalarType) children.get(1).type).getScalarScale()) { castChild(type, 1); } - } else if (op == Operator.DIVIDE && (t2Scale != 0) && t1.isDecimalV3()) { + } else if (op == Operator.DIVIDE && (t2Scale != 0) && t1TargetType.isDecimalV3()) { int targetScale = t1Scale + t2Scale; if (precision < targetScale) { type = castBinaryOp(Type.DOUBLE); diff --git a/regression-test/data/datatype_p0/decimalv3/test_arithmetic_expressions.out b/regression-test/data/datatype_p0/decimalv3/test_arithmetic_expressions.out index 085b844d7c8..7f29407e103 100644 --- a/regression-test/data/datatype_p0/decimalv3/test_arithmetic_expressions.out +++ b/regression-test/data/datatype_p0/decimalv3/test_arithmetic_expressions.out @@ -47,3 +47,9 @@ -- !select -- 10999999.989 +-- !select -- +1 629.028702933 629.028702933 +2 722.810212429 722.810212429 +3 724.291976000 724.291976000 +4 688.890183155 688.890183155 + diff --git a/regression-test/suites/datatype_p0/decimalv3/test_arithmetic_expressions.groovy b/regression-test/suites/datatype_p0/decimalv3/test_arithmetic_expressions.groovy index 284cf482e43..b077e4c3621 100644 --- a/regression-test/suites/datatype_p0/decimalv3/test_arithmetic_expressions.groovy +++ b/regression-test/suites/datatype_p0/decimalv3/test_arithmetic_expressions.groovy @@ -65,4 +65,26 @@ suite("test_arithmetic_expressions") { qt_select "select (a + b + c) / d from ${table1};" qt_select "select a + b + c + d + e + f + g + h + i + j + k from ${table1};" sql "drop table if exists ${table1}" + + def table2 = "test_arithmetic_expressions" + + sql "drop table if exists ${table2}" + sql """ create table ${table2} ( + id smallint, + fz decimal(27,9), + fzv3 decimalv3(27,9), + fm decimalv3(38,10)) + DISTRIBUTED BY HASH(`id`) BUCKETS auto + PROPERTIES + ( + "replication_num" = "1" + ); """ + + sql """ insert into ${table2} values (1,92594283.129196000,92594283.129196000,147202.0000000000); """ + sql """ insert into ${table2} values (2,107684988.257976000,107684988.257976000,148981.0000000000); """ + sql """ insert into ${table2} values (3,76891560.464178000,76891560.464178000,106161.0000000000); """ + sql """ insert into ${table2} values (4,277170831.851350000,277170831.851350000,402344.0000000000); """ + + qt_select """ select id, fz/fm as dec,fzv3/fm as decv3 from ${table2} ORDER BY id; """ + sql "drop table if exists ${table2}" } --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org