From 1e95d4b647d709ca130c70590e7feed48a085cb0 Mon Sep 17 00:00:00 2001 From: Yongting You <2010youy01@gmail.com> Date: Tue, 21 Jul 2026 15:39:32 +0800 Subject: [PATCH 1/5] test: improve round SQL coverage --- datafusion/sqllogictest/test_files/math.slt | 86 +++++++++++++++++++++ 1 file changed, 86 insertions(+) diff --git a/datafusion/sqllogictest/test_files/math.slt b/datafusion/sqllogictest/test_files/math.slt index 583d6f6777865..47ed0c26f4eaf 100644 --- a/datafusion/sqllogictest/test_files/math.slt +++ b/datafusion/sqllogictest/test_files/math.slt @@ -88,6 +88,92 @@ SELECT round(125.2345, -3), round(125.2345, -2), round(125.2345, -1), round(125. ---- 0 100 130 125 125 125.2 125.23 125.235 +# Round signed and unsigned integer scalar widths +query IIIIIIII +SELECT + round(arrow_cast('115', 'Int8'), -1), + round(arrow_cast('-115', 'Int16'), -1), + round(arrow_cast('115', 'Int32'), -1), + round(arrow_cast('-115', 'Int64'), -1), + round(arrow_cast('115', 'UInt8'), -1), + round(arrow_cast('115', 'UInt16'), -1), + round(arrow_cast('115', 'UInt32'), -1), + round(arrow_cast('115', 'UInt64'), -1); +---- +120 -120 120 -120 120 120 120 120 + +# Round signed and unsigned integer arrays, including null and oversized scales +query IIIIIIII +SELECT + round(arrow_cast(column1, 'Int8'), column2), + round(arrow_cast(column1, 'Int16'), column2), + round(arrow_cast(column1, 'Int32'), column2), + round(arrow_cast(column1, 'Int64'), column2), + round(arrow_cast(column1, 'UInt8'), column2), + round(arrow_cast(column1, 'UInt16'), column2), + round(arrow_cast(column1, 'UInt32'), column2), + round(arrow_cast(column1, 'UInt64'), column2) +FROM (VALUES ('115', -1), ('0', -1), (NULL, -20)) AS t(column1, column2); +---- +120 120 120 120 120 120 120 120 +0 0 0 0 0 0 0 0 +NULL NULL NULL NULL NULL NULL NULL NULL + +# Round all decimal widths as scalars +query RRRR +SELECT + round(arrow_cast('125.55', 'Decimal32(7,2)'), 1), + round(arrow_cast('-125.55', 'Decimal64(16,2)'), 1), + round(arrow_cast('125.55', 'Decimal128(30,2)'), 1), + round(arrow_cast('-125.55', 'Decimal256(40,2)'), 1); +---- +125.6 -125.6 125.6 -125.6 + +# Round all decimal widths as arrays with per-row decimal places +query RRRR +SELECT + round(arrow_cast(column1, 'Decimal32(7,2)'), column2), + round(arrow_cast(column1, 'Decimal64(16,2)'), column2), + round(arrow_cast(column1, 'Decimal128(30,2)'), column2), + round(arrow_cast(column1, 'Decimal256(40,2)'), column2) +FROM (VALUES ('125.55', 1), ('-125.55', 0), ('125.55', -1), (NULL, 1)) AS t(column1, column2); +---- +125.6 125.6 125.6 125.6 +-126 -126 -126 -126 +130 130 130 130 +NULL NULL NULL NULL + +# Float arrays with scalar and per-row decimal places +query RRRR +SELECT + round(arrow_cast(column1, 'Float32'), 1), + round(arrow_cast(column1, 'Float64'), 1), + round(arrow_cast(column1, 'Float32'), column2), + round(arrow_cast(column1, 'Float64'), column2) +FROM (VALUES ('125.55', 1), ('-125.55', 0), (NULL, -1)) AS t(column1, column2); +---- +125.6 125.6 125.6 125.6 +-125.6 -125.6 -126 -126 +NULL NULL NULL NULL + +# Null decimal places, invalid argument count/type, and out-of-range scale +query R +SELECT round(1.25, NULL); +---- +NULL + +query error DataFusion error: +SELECT round(); + +query error DataFusion error: +SELECT round(1, 2, 3); + +query error DataFusion error: +SELECT round('x'); + +query error round decimal_places 2147483648 is out of supported i32 range +SELECT round(1.25, 2147483648); + # atan2 query RRRRRRR SELECT atan2(2.0, 1.0), atan2(-2.0, 1.0), atan2(2.0, -1.0), atan2(-2.0, -1.0), atan2(NULL, 1.0), atan2(2.0, NULL), atan2(NULL, NULL); From ef7f0434773d0e68ac1784f3dbaaf12841e0e1db Mon Sep 17 00:00:00 2001 From: Yongting You <2010youy01@gmail.com> Date: Thu, 30 Jul 2026 15:12:47 +0800 Subject: [PATCH 2/5] tighten error message check --- datafusion/sqllogictest/test_files/math.slt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/datafusion/sqllogictest/test_files/math.slt b/datafusion/sqllogictest/test_files/math.slt index 47ed0c26f4eaf..a36128708b966 100644 --- a/datafusion/sqllogictest/test_files/math.slt +++ b/datafusion/sqllogictest/test_files/math.slt @@ -162,13 +162,13 @@ SELECT round(1.25, NULL); ---- NULL -query error DataFusion error: +query error Error during planning: 'round' does not support zero arguments. SELECT round(); -query error DataFusion error: +query error Error during planning: Internal error: Function 'round' failed to match any signature SELECT round(1, 2, 3); -query error DataFusion error: +query error Error during planning: Internal error: Function 'round' failed to match any signature SELECT round('x'); query error round decimal_places 2147483648 is out of supported i32 range From 0336eb64e50b3c1fb3f8444724ae023b3d3f0303 Mon Sep 17 00:00:00 2001 From: Yongting You <2010youy01@gmail.com> Date: Thu, 30 Jul 2026 16:18:53 +0800 Subject: [PATCH 3/5] fix ci --- datafusion/sqllogictest/test_files/math.slt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/datafusion/sqllogictest/test_files/math.slt b/datafusion/sqllogictest/test_files/math.slt index a36128708b966..76d58d27da804 100644 --- a/datafusion/sqllogictest/test_files/math.slt +++ b/datafusion/sqllogictest/test_files/math.slt @@ -162,7 +162,7 @@ SELECT round(1.25, NULL); ---- NULL -query error Error during planning: 'round' does not support zero arguments. +query error DataFusion error: Error during planning: 'round' does not support zero arguments. SELECT round(); query error Error during planning: Internal error: Function 'round' failed to match any signature From 305dcb816224217bdd0b3aa2a44bf8042922d813 Mon Sep 17 00:00:00 2001 From: Yongting You <2010youy01@gmail.com> Date: Thu, 30 Jul 2026 17:16:20 +0800 Subject: [PATCH 4/5] fix ci --- datafusion/sqllogictest/test_files/math.slt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/datafusion/sqllogictest/test_files/math.slt b/datafusion/sqllogictest/test_files/math.slt index 76d58d27da804..cf7803d276703 100644 --- a/datafusion/sqllogictest/test_files/math.slt +++ b/datafusion/sqllogictest/test_files/math.slt @@ -162,7 +162,7 @@ SELECT round(1.25, NULL); ---- NULL -query error DataFusion error: Error during planning: 'round' does not support zero arguments. +query error DataFusion error: Error during planning: 'round' does not support zero arguments SELECT round(); query error Error during planning: Internal error: Function 'round' failed to match any signature From a3ec5679103bc7e03b0b76cf3d7b8c9963335a5c Mon Sep 17 00:00:00 2001 From: Yongting You <2010youy01@gmail.com> Date: Thu, 30 Jul 2026 18:03:46 +0800 Subject: [PATCH 5/5] more coverage to no null columns --- datafusion/sqllogictest/test_files/math.slt | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/datafusion/sqllogictest/test_files/math.slt b/datafusion/sqllogictest/test_files/math.slt index cf7803d276703..c019ed74720d3 100644 --- a/datafusion/sqllogictest/test_files/math.slt +++ b/datafusion/sqllogictest/test_files/math.slt @@ -119,6 +119,16 @@ FROM (VALUES ('115', -1), ('0', -1), (NULL, -20)) AS t(column1, column2); 0 0 0 0 0 0 0 0 NULL NULL NULL NULL NULL NULL NULL NULL +# Test columns without null +query I +SELECT + round(column1, column2) +FROM (VALUES (115, -20), (0, -1), (21, -1)) AS t(column1, column2); +---- +0 +0 +20 + # Round all decimal widths as scalars query RRRR SELECT