Repository navigation
Fix inf/NaN comparisons for FLOAT orderby in window functions - #13635
Merged
rapids-bot[bot] merged 14 commits intoJul 5, 2023
Merged
Conversation
This is a follow-up to NVIDIA#13512 (which added support for floating point order-by columns in window functions), and NVIDIA#13606 (which fixed how negative values are handled for floating point order-by). This commit fixes how `NaN` and `+/- Infinity` values are handled for floating point. Prior to this commit, the calculations for range window extents depended on the behaviour of `thrust::less<float>` and `thrust::greater<float>`, as well as addition/subtraction on `+/- Infinity`. This produced some unexpected results: 1. `thrust::less`/`greater` on `NaN` does not produce strict ordering. 2. Addition/Subtraction on the numerical values of `Infinity` could produce finite values that interfere with window extent calculations. Ideally, the results should have remained infinite. This commit adds custom comparators with `NaN` awareness, to better handle columns that contain `NaN`s. It also fixes range calculations where `Infinity` is involved. Tests have been added to cover ASC/DESC order sorting on `FLOAT`, with `NaN` and `Infinity` values.
mythrocks
added a commit
to mythrocks/spark-rapids
that referenced
this pull request
Jun 28, 2023
Depends on NVIDIA/cudf#13635. This commit adds support for floating point order-by columns in RANGE based window functions. Prior to this commit, when the `GpuWindowExec` was presented with an order-by column of floating-point type, the entire window operation would fall back to CPU execution. This should now execute entirely on the GPU.
vuule
reviewed
Jun 29, 2023
vuule
reviewed
Jun 29, 2023
vuule
left a comment
Contributor
There was a problem hiding this comment.
few small comments. Mostly confused about ordering when one element is NaN.
mythrocks
added a commit
to mythrocks/spark-rapids
that referenced
this pull request
Jun 29, 2023
Depends on NVIDIA/cudf#13635. This commit adds support for floating point order-by columns in RANGE based window functions. Prior to this commit, when the `GpuWindowExec` was presented with an order-by column of floating-point type, the entire window operation would fall back to CPU execution. This should now execute entirely on the GPU.
mythrocks
added a commit
to mythrocks/spark-rapids
that referenced
this pull request
Jun 29, 2023
Depends on NVIDIA/cudf#13635. This commit adds support for floating point order-by columns in RANGE based window functions. Prior to this commit, when the `GpuWindowExec` was presented with an order-by column of floating-point type, the entire window operation would fall back to CPU execution. This should now execute entirely on the GPU.
mythrocks
added a commit
to mythrocks/spark-rapids
that referenced
this pull request
Jun 29, 2023
Depends on NVIDIA/cudf#13635. This commit adds support for floating point order-by columns in RANGE based window functions. Prior to this commit, when the `GpuWindowExec` was presented with an order-by column of floating-point type, the entire window operation would fall back to CPU execution. This should now execute entirely on the GPU. Example query: ```sql SELECT COUNT(1) OVER (PARTITION BY grp ORDER BY float_column RANGE BETWEEN 1.023 PRECEDING AND 3.14159 FOLLOWING) FROM my_float_table; ```
mythrocks
added a commit
to mythrocks/spark-rapids
that referenced
this pull request
Jun 29, 2023
Depends on NVIDIA/cudf#13635. This commit adds support for floating point order-by columns in RANGE based window functions. Prior to this commit, when the `GpuWindowExec` was presented with an order-by column of floating-point type, the entire window operation would fall back to CPU execution. This should now execute entirely on the GPU. Example query: ```sql SELECT COUNT(1) OVER (PARTITION BY grp ORDER BY float_column RANGE BETWEEN 1.023 PRECEDING AND 3.14159 FOLLOWING) FROM my_float_table; ``` Signed-off-by: MithunR <[email protected]>
1. Document why nan-aware comparators are required. 2. Reuse thrust::less and thrust::greater.
Contributor
Author
|
I've added tests for the |
vuule
approved these changes
Jul 4, 2023
vuule
left a comment
Contributor
There was a problem hiding this comment.
Love the test coverage, thank you for taking the time to add the unit tests.
hyperbolic2346
approved these changes
Jul 5, 2023
hyperbolic2346
left a comment
Contributor
There was a problem hiding this comment.
This is a nice change and the tests added are very welcome.
nvdbaranec
approved these changes
Jul 5, 2023
nvdbaranec
left a comment
Contributor
There was a problem hiding this comment.
lgtm. One small typo in comment block.
Contributor
Author
|
/merge |
Contributor
Author
|
Thank you for the reviews, all. I have merged this change. |
mythrocks
added a commit
to NVIDIA/cudf-spark
that referenced
this pull request
Jul 10, 2023
#8637) * Support Float order-by columns for RANGE window functions Depends on NVIDIA/cudf#13635. This commit adds support for floating point order-by columns in RANGE based window functions. Prior to this commit, when the `GpuWindowExec` was presented with an order-by column of floating-point type, the entire window operation would fall back to CPU execution. This should now execute entirely on the GPU. Example query: ```sql SELECT COUNT(1) OVER (PARTITION BY grp ORDER BY float_column RANGE BETWEEN 1.023 PRECEDING AND 3.14159 FOLLOWING) FROM my_float_table; ``` Signed-off-by: MithunR <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This is a follow-up to #13512 (which added support for floating point order-by columns in window functions), and #13606 (which fixed how negative values are handled for floating point order-by).
This commit fixes how
NaNand+/- Infinityvalues are handled for floating point.Prior to this commit, the calculations for range window extents depended on the behaviour of
thrust::less<float>andthrust::greater<float>, as well as addition/subtraction on+/- Infinity. This produced some unexpected results:thrust::less/greateronNaNdoes not produce strict ordering.Infinitycould produce finite values that interfere with window extent calculations. Ideally, the results should have remained infinite.This commit adds custom comparators with
NaNawareness, to better handle columns that containNaNs. It also fixes range calculations whereInfinityis involved.Tests have been added to cover ASC/DESC order sorting on
FLOAT, withNaNandInfinityvalues.Checklist