-
Notifications
You must be signed in to change notification settings - Fork 885
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix floating point window range extents. #13606
Merged
rapids-bot
merged 1 commit into
rapidsai:branch-23.08
from
mythrocks:fix-float-min-range
Jun 26, 2023
Merged
Fix floating point window range extents. #13606
rapids-bot
merged 1 commit into
rapidsai:branch-23.08
from
mythrocks:fix-float-min-range
Jun 26, 2023
Conversation
This file contains 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
This commit fixes the window range calculations for floating-point order by columns. Window range calculations involve comparing the `delta` value (preceding/following) with the current row value, and capping `current_row - delta` at `numeric_limits::min()`. It turns out that for `float`/`double` values, `numeric_limits::min()` returns `FLT_MIN` which is the lowest positive finite float value. This causes the erstwhile logic to produce incorrect results when the order-by column contains negative float values. The fix involves replacing `numeric_limits::min()` with `numeric_limits::lowest()` which returns the true min float value. Reference: 1. https://en.cppreference.com/w/cpp/types/numeric_limits/min
mythrocks
added
bug
Something isn't working
improvement
Improvement / enhancement to an existing function
non-breaking
Non-breaking change
labels
Jun 22, 2023
mythrocks
removed
the
improvement
Improvement / enhancement to an existing function
label
Jun 22, 2023
github-actions
bot
added
libcudf
Affects libcudf (C++/CUDA) code.
improvement
Improvement / enhancement to an existing function
labels
Jun 22, 2023
mythrocks
removed
the
improvement
Improvement / enhancement to an existing function
label
Jun 22, 2023
harrism
approved these changes
Jun 22, 2023
ttnghia
approved these changes
Jun 24, 2023
/merge |
mythrocks
added a commit
to mythrocks/cudf
that referenced
this pull request
Jun 28, 2023
This is a follow-up to rapidsai#13512 (which added support for floating point order-by columns in window functions), and rapidsai#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.
3 tasks
rapids-bot bot
pushed a commit
that referenced
this pull request
Jul 5, 2023
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 `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. Authors: - MithunR (https://github.com/mythrocks) Approvers: - Vukasin Milovanovic (https://github.com/vuule) - Mike Wilson (https://github.com/hyperbolic2346) - https://github.com/nvdbaranec URL: #13635
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
bug
Something isn't working
libcudf
Affects libcudf (C++/CUDA) code.
non-breaking
Non-breaking change
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 commit fixes the window range calculations for floating-point order by columns.
Window range calculations involve comparing the
delta
value (preceding/following) with the current row value, and cappingcurrent_row - delta
atnumeric_limits::min()
.It turns out that for
float
/double
values,numeric_limits::min()
returnsFLT_MIN
which is the lowest positive finite float value. This causes the erstwhile logic to produce incorrect results when the order-by column contains negative float values.The fix involves replacing
numeric_limits::min()
withnumeric_limits::lowest()
which returns the true min float value.Reference:
Checklist