You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@datafusion.apache.org by "2010YOUY01 (via GitHub)" <gi...@apache.org> on 2026/07/29 09:39:08 UTC
[PR] test: improve `round` sqllogictest coverage [datafusion]
2010YOUY01 opened a new pull request, #23973:
URL: https://github.com/apache/datafusion/pull/23973
## Which issue does this PR close?
<!--
We generally require a GitHub issue to be filed for all bug fixes and enhancements and this helps us generate change logs for our releases. You can link an issue to this PR using the GitHub syntax. For example `Closes #123` indicates that this PR will close issue #123.
-->
- Closes #.
## Rationale for this change
<!--
Why are you proposing this change? If this is already explained clearly in the issue then this section is not needed.
Explaining clearly why changes are proposed helps reviewers understand your changes and offer better suggestions for fixes.
-->
Codecov reports low test coverage for this function, so this PR adds more SLT tests for it.
The tests were AI-generated, and I manually verified that the results are correct.
See `Codecov` bot comment -> `☔ View full report in Codecov by Harness` -> `Indirect Changes` for the updated test coverage.
## What changes are included in this PR?
<!--
There is no need to duplicate the description in the issue here but it is sometimes worth providing a summary of the individual changes in this PR.
-->
## Are these changes tested?
<!--
We typically require tests for all PRs in order to:
1. Prevent the code from being accidentally broken by subsequent changes
2. Serve as another way to document the expected behavior of the code
If tests are not included in your PR, please explain why (for example, are they covered by existing tests)?
-->
## Are there any user-facing changes?
<!--
If there are user-facing changes then we may require documentation to be updated before approving the PR.
-->
<!--
If there are any breaking changes to public APIs, please add the `api change` label.
-->
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
Re: [PR] test: improve `round` sqllogictest coverage [datafusion]
Posted by "neilconway (via GitHub)" <gi...@apache.org>.
neilconway commented on code in PR #23973:
URL: https://github.com/apache/datafusion/pull/23973#discussion_r3675305854
##########
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');
Review Comment:
Can we make the error matches more precise?
##########
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
Review Comment:
I think we'd benefit from another test row that checks oversized scales but does not have a NULL in `column1` (since NULLs take a different code path). e.g., `('115', -20)`
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
Re: [PR] test: improve `round` sqllogictest coverage [datafusion]
Posted by "neilconway (via GitHub)" <gi...@apache.org>.
neilconway merged PR #23973:
URL: https://github.com/apache/datafusion/pull/23973
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
Re: [PR] test: improve `round` sqllogictest coverage [datafusion]
Posted by "codecov-commenter (via GitHub)" <gi...@apache.org>.
codecov-commenter commented on PR #23973:
URL: https://github.com/apache/datafusion/pull/23973#issuecomment-5117410543
## [Codecov](https://app.codecov.io/gh/apache/datafusion/pull/23973?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) Report
:white_check_mark: All modified and coverable lines are covered by tests.
:white_check_mark: Project coverage is 80.78%. Comparing base ([`02a902c`](https://app.codecov.io/gh/apache/datafusion/commit/02a902c7ff061b574fbf64e504812235558ff161?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)) to head ([`1e95d4b`](https://app.codecov.io/gh/apache/datafusion/commit/1e95d4b647d709ca130c70590e7feed48a085cb0?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)).
:warning: Report is 113 commits behind head on main.
<details><summary>Additional details and impacted files</summary>
```diff
@@ Coverage Diff @@
## main #23973 +/- ##
==========================================
+ Coverage 80.71% 80.78% +0.07%
==========================================
Files 1089 1096 +7
Lines 368293 373282 +4989
Branches 368293 373282 +4989
==========================================
+ Hits 297250 301555 +4305
- Misses 53332 53737 +405
- Partials 17711 17990 +279
```
</details>
[:umbrella: View full report in Codecov by Harness](https://app.codecov.io/gh/apache/datafusion/pull/23973?dropdown=coverage&src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
:loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
<details><summary> :rocket: New features to boost your workflow: </summary>
- :snowflake: [Test Analytics](https://docs.codecov.com/docs/test-analytics): Detect flaky tests, report on failures, and find test suite problems.
- :package: [JS Bundle Analysis](https://docs.codecov.com/docs/javascript-bundle-analysis): Save yourself from yourself by tracking and limiting bundle sizes in JS merges.
</details>
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
Re: [PR] test: improve `round` sqllogictest coverage [datafusion]
Posted by "2010YOUY01 (via GitHub)" <gi...@apache.org>.
2010YOUY01 commented on code in PR #23973:
URL: https://github.com/apache/datafusion/pull/23973#discussion_r3681801172
##########
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
Review Comment:
Good point, updated.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
Re: [PR] test: improve `round` sqllogictest coverage [datafusion]
Posted by "2010YOUY01 (via GitHub)" <gi...@apache.org>.
2010YOUY01 commented on code in PR #23973:
URL: https://github.com/apache/datafusion/pull/23973#discussion_r3681724383
##########
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');
Review Comment:
updated
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org