From cdc81896974b0266d56fb336e92864eb9c1fd51e Mon Sep 17 00:00:00 2001 From: zhiqqqq Date: Mon, 25 Sep 2023 10:39:45 +0800 Subject: [PATCH] [Impro](regression-test) More test cases for function round (#24791) --- .../math_functions/test_round.out | 24 +++++++++++++++++++ .../math_functions/test_round.groovy | 5 ++++ 2 files changed, 29 insertions(+) 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 162e5970db37e1..bbc66e5b976671 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,30 @@ -- !select -- 10.12 +-- !select -- +0.0 0.0 +0.5 0.0 +1.0 1.0 +1.5 2.0 +2.0 2.0 +2.5 2.0 +3.0 3.0 +3.5 4.0 +4.0 4.0 +4.5 4.0 + +-- !select -- +0.0 0.0 +0.5 1.0 +1.0 1.0 +1.5 2.0 +2.0 2.0 +2.5 3.0 +3.0 3.0 +3.5 4.0 +4.0 4.0 +4.5 5.0 + -- !truncate -- 1 1989 1001 123.1 0.1 6.3 2 1986 1001 1243.5 20.2 789.2 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 f9b271b24bea73..4f20f36c7b0528 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,11 @@ qt_select "SELECT round_bankers(10.12345)" qt_select "SELECT round_bankers(10.12345, 2)" + // test tie case 1: float, banker's rounding + qt_select "SELECT number*10/100 AS x, ROUND(number * 10 / 100) from NUMBERS('number'=50) where number % 5 = 0 ORDER BY x;" + // test tie case 2: decimal, rounded up when tie + qt_select "SELECT number*10/100 AS x, ROUND(CAST(number * 10 AS DECIMALV3(10,2)) / 100) from NUMBERS('number'=50) where number % 5 = 0 ORDER BY x;" + 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;"