You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by da...@apache.org on 2023/04/11 03:10:54 UTC
[doris] branch branch-1.2-lts updated: [Bug](round) fix wrong scale for round-like function (#18507) (#18534)
This is an automated email from the ASF dual-hosted git repository.
dataroaring 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 a2f92be7a7 [Bug](round) fix wrong scale for round-like function (#18507) (#18534)
a2f92be7a7 is described below
commit a2f92be7a707e5d2f434c413057aec0621b838b2
Author: Gabriel <ga...@gmail.com>
AuthorDate: Tue Apr 11 11:10:47 2023 +0800
[Bug](round) fix wrong scale for round-like function (#18507) (#18534)
---
.../src/main/java/org/apache/doris/analysis/FunctionCallExpr.java | 2 +-
.../data/query_p0/sql_functions/math_functions/test_round.out | 2 +-
.../suites/query_p0/sql_functions/math_functions/test_round.groovy | 1 -
3 files changed, 2 insertions(+), 3 deletions(-)
diff --git a/fe/fe-core/src/main/java/org/apache/doris/analysis/FunctionCallExpr.java b/fe/fe-core/src/main/java/org/apache/doris/analysis/FunctionCallExpr.java
index e562706073..2500e67b7e 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/analysis/FunctionCallExpr.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/analysis/FunctionCallExpr.java
@@ -119,7 +119,7 @@ public class FunctionCallExpr extends Expr {
}
int scaleArg = (int) (((IntLiteral) children.get(1)).getValue());
return ScalarType.createDecimalV3Type(children.get(0).getType().getPrecision(),
- Math.max(scaleArg, 0));
+ Math.min(Math.max(scaleArg, 0), ((ScalarType) children.get(0).getType()).decimalScale()));
} else {
return returnType;
}
diff --git a/regression-test/data/query_p0/sql_functions/math_functions/test_round.out b/regression-test/data/query_p0/sql_functions/math_functions/test_round.out
index 6363a18165..d82966882d 100644
--- a/regression-test/data/query_p0/sql_functions/math_functions/test_round.out
+++ b/regression-test/data/query_p0/sql_functions/math_functions/test_round.out
@@ -1,6 +1,6 @@
-- This file is automatically generated. You should know what you did if you want to edit this
-- !select --
-10.0
+10
-- !select --
10.12
diff --git a/regression-test/suites/query_p0/sql_functions/math_functions/test_round.groovy b/regression-test/suites/query_p0/sql_functions/math_functions/test_round.groovy
index fa00278981..3e2f698c2a 100644
--- a/regression-test/suites/query_p0/sql_functions/math_functions/test_round.groovy
+++ b/regression-test/suites/query_p0/sql_functions/math_functions/test_round.groovy
@@ -18,7 +18,6 @@
suite("test_round") {
// vectorized
sql """ set enable_vectorized_engine = true """
-
qt_select "SELECT round(10.12345)"
qt_select "SELECT round(10.12345, 2)"
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org