This is an automated email from the ASF dual-hosted git repository. github-merge-queue[bot] pushed a commit to branch gh-readonly-queue/main/pr-23754-5392f69b3ac5c746bd44c3de881a48217bbc86cd in repository https://gitbox.apache.org/repos/asf/datafusion.git
commit 092ec9ed2669859c9ae08a4a2e7a7285f01956be Author: Yongting You <[email protected]> AuthorDate: Thu Jul 23 09:33:34 2026 +0800 test: improve `isnan` function SQL test coverage (#23754) ## 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. --> --- 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 7c24496230..2e9107dc6e 100644 --- a/datafusion/sqllogictest/test_files/math.slt +++ b/datafusion/sqllogictest/test_files/math.slt @@ -127,6 +127,92 @@ SELECT isnan(1::DECIMAL(10,2)), isnan(0::DECIMAL(10,2)), isnan(NULL::DECIMAL(10, ---- false false NULL false +# isnan: scalar values at the remaining numeric widths +query BBBBBBBBBB +SELECT + isnan(arrow_cast('NaN', 'Float16')), + isnan(arrow_cast('-1.5', 'Float16')), + isnan(arrow_cast('-128', 'Int8')), + isnan(arrow_cast('-32768', 'Int16')), + isnan(arrow_cast('-9223372036854775808', 'Int64')), + isnan(arrow_cast('65535', 'UInt16')), + isnan(arrow_cast('18446744073709551615', 'UInt64')), + isnan(arrow_cast('1.25', 'Decimal32(7,2)')), + isnan(arrow_cast('-12.34', 'Decimal64(16,2)')), + isnan(arrow_cast('0.00', 'Decimal256(40,2)')) +---- +true false false false false false false false false false + +# isnan: floating-point arrays, including infinities and nulls +query IBBB +SELECT id, + isnan(arrow_cast(v, 'Float16')), + isnan(arrow_cast(v, 'Float32')), + isnan(arrow_cast(v, 'Float64')) +FROM (VALUES + (1, 'NaN'), + (2, 'Infinity'), + (3, '-Infinity'), + (4, '0.0'), + (5, NULL) +) AS t(id, v) +ORDER BY id +---- +1 true true true +2 false false false +3 false false false +4 false false false +5 NULL NULL NULL + +# isnan: signed and unsigned integer arrays +query IBBBBBBBB +SELECT id, + isnan(arrow_cast(v, 'Int8')), + isnan(arrow_cast(v, 'Int16')), + isnan(arrow_cast(v, 'Int32')), + isnan(arrow_cast(v, 'Int64')), + isnan(arrow_cast(v, 'UInt8')), + isnan(arrow_cast(v, 'UInt16')), + isnan(arrow_cast(v, 'UInt32')), + isnan(arrow_cast(v, 'UInt64')) +FROM (VALUES (1, '0'), (2, '42'), (3, NULL)) AS t(id, v) +ORDER BY id +---- +1 false false false false false false false false +2 false false false false false false false false +3 NULL NULL NULL NULL NULL NULL NULL NULL + +# isnan: decimal arrays at every Arrow decimal width +query IBBBB +SELECT id, + isnan(arrow_cast(v, 'Decimal32(7,2)')), + isnan(arrow_cast(v, 'Decimal64(16,2)')), + isnan(arrow_cast(v, 'Decimal128(30,2)')), + isnan(arrow_cast(v, 'Decimal256(40,2)')) +FROM (VALUES (1, '0.00'), (2, '-12.34'), (3, NULL)) AS t(id, v) +ORDER BY id +---- +1 false false false false +2 false false false false +3 NULL NULL NULL NULL + +# isnan: an untyped all-null array +query B +SELECT isnan(v) FROM (VALUES (NULL), (NULL)) AS t(v) +---- +NULL +NULL + +# isnan: invalid argument count and type +statement error +SELECT isnan() + +statement error +SELECT isnan(1, 2) + +statement error +SELECT isnan('not numeric') + # iszero query BBBB SELECT iszero(1.0), iszero(0.0), iszero(-0.0), iszero(NULL) --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
