This is an automated email from the ASF dual-hosted git repository.
yiguolei 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 289a4b2ea4 [fix](func) fix truncate float type result error (#16468)
289a4b2ea4 is described below
commit 289a4b2ea40b4481999a853de357d69895e1cbce
Author: luozenglin <[email protected]>
AuthorDate: Wed Feb 8 08:57:43 2023 +0800
[fix](func) fix truncate float type result error (#16468)
When the argument of truncate function is float type, it can match both
truncate(DECIMALV3) and truncate(DOUBLE), if the match is truncate(DECIMALV3),
the precision is lost when converting float to DECIMALV3(38, 0).
Here I modify it to match truncate(DOUBLE) for now, maybe we still need to
solve the problem of losing precision when converting float to DECIMALV3.
---
gensrc/script/doris_builtins_functions.py | 2 +-
.../data/query_p0/sql_functions/math_functions/test_round.out | 5 +++++
.../suites/query_p0/sql_functions/math_functions/test_round.groovy | 3 +++
3 files changed, 9 insertions(+), 1 deletion(-)
diff --git a/gensrc/script/doris_builtins_functions.py
b/gensrc/script/doris_builtins_functions.py
index 26e93be7b5..5222b6ce8d 100644
--- a/gensrc/script/doris_builtins_functions.py
+++ b/gensrc/script/doris_builtins_functions.py
@@ -980,10 +980,10 @@ visible_functions = [
[['ceil', 'dceil'], 'DECIMAL32', ['DECIMAL32', 'INT'], ''],
[['ceil', 'dceil'], 'DECIMAL64', ['DECIMAL64', 'INT'], ''],
[['ceil', 'dceil'], 'DECIMAL128', ['DECIMAL128', 'INT'], ''],
+ [['truncate'], 'DOUBLE', ['DOUBLE', 'INT'], ''],
[['truncate'], 'DECIMAL32', ['DECIMAL32', 'INT'], ''],
[['truncate'], 'DECIMAL64', ['DECIMAL64', 'INT'], ''],
[['truncate'], 'DECIMAL128', ['DECIMAL128', 'INT'], ''],
- [['truncate'], 'DOUBLE', ['DOUBLE', 'INT'], ''],
[['ln', 'dlog1'], 'DOUBLE', ['DOUBLE'], 'ALWAYS_NULLABLE'],
[['log'], 'DOUBLE', ['DOUBLE', 'DOUBLE'], 'ALWAYS_NULLABLE'],
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 3f2ff0ab96..a847c8b2a9 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
@@ -11,6 +11,11 @@
-- !select --
10.12
+-- !truncate --
+1.0 1989.0 1001.0 123.1 0.1 6.3
+2.0 1986.0 1001.0 1243.5 20.2 789.2
+3.0 1989.0 1002.0 24453.3 78945.0 3654.0
+
-- !select --
16.000 16.00000 16.00000
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 d56cd0fac4..b30f35f78a 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
@@ -21,6 +21,9 @@ suite("test_round") {
qt_select "SELECT round_bankers(10.12345)"
qt_select "SELECT round_bankers(10.12345, 2)"
+ def tableTest = "test_query_db.test"
+ qt_truncate "select truncate(k1, 1), truncate(k2, 1), truncate(k3, 1),
truncate(k5, 1), truncate(k8, 1), truncate(k9, 1) from ${tableTest} order by 1;"
+
def tableName = "test_round"
sql """DROP TABLE IF EXISTS `${tableName}`"""
sql """ CREATE TABLE `${tableName}` (
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]