Skip to content
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

[REVIEW] Clip decimal binary op precision at max precision #8194

Merged
merged 6 commits into from
May 27, 2021

Conversation

ChrisJar
Copy link
Contributor

@ChrisJar ChrisJar commented May 10, 2021

This fixes an issue where the precision assigned to the result of a decimal binary operation may exceed the maximum precision.

Closes #8291

@ChrisJar ChrisJar requested a review from a team as a code owner May 10, 2021 17:07
@ChrisJar ChrisJar requested review from cwharris and isVoid May 10, 2021 17:07
@github-actions github-actions bot added the Python Affects Python cuDF API. label May 10, 2021
@ChrisJar ChrisJar changed the title Clip decimal binary op precision at max precision [REVIEW] Clip decimal binary op precision at max precision May 10, 2021
@codecov
Copy link

codecov bot commented May 10, 2021

Codecov Report

❗ No coverage uploaded for pull request base (branch-21.06@bbce6bc). Click here to learn what that means.
The diff coverage is n/a.

Impacted file tree graph

@@               Coverage Diff               @@
##             branch-21.06    #8194   +/-   ##
===============================================
  Coverage                ?   82.84%           
===============================================
  Files                   ?      105           
  Lines                   ?    17866           
  Branches                ?        0           
===============================================
  Hits                    ?    14801           
  Misses                  ?     3065           
  Partials                ?        0           

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update bbce6bc...9ed25ce. Read the comment docs.

Copy link
Contributor

@isVoid isVoid left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we add to the docstring of _binop_precision mentioning that this helper function does not guarantee result to be bounded by cudf.Decimal64Dtype.MAX_PRECISION?

@ChrisJar ChrisJar requested a review from isVoid May 11, 2021 21:20
Copy link
Contributor

@cwharris cwharris left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm, but have a question.

python/cudf/cudf/core/column/decimal.py Outdated Show resolved Hide resolved
Copy link
Contributor

@isVoid isVoid left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry about the back and forth. Just a small comment reverting my previous review.

python/cudf/cudf/core/column/decimal.py Outdated Show resolved Hide resolved
@cwharris
Copy link
Contributor

Does this PR close an issue, and if so can you reference it here?

@ChrisJar
Copy link
Contributor Author

Does this PR close an issue, and if so can you reference it here?

Nope, there's no issue related to this problem

@cwharris
Copy link
Contributor

@ChrisJar In that case is there more context we can add to this PR? Adding some tests that would have previously failed, and/or providing the error that was being encountered previously could prove useful if we end up with a regression later on.

@ChrisJar
Copy link
Contributor Author

@ChrisJar In that case is there more context we can add to this PR? Adding some tests that would have previously failed, and/or providing the error that was being encountered previously could prove useful if we end up with a regression later on.

Yep! Will do

@isVoid
Copy link
Contributor

isVoid commented May 20, 2021

Thanks to @cwharris 's question that prompted me to think deeper: since we compute the precisions pessimistically, when clipping happens, it means the operation might have produced an overflow. Do we need to introspect the data to tell if the overflow has happened? What is current behavior when overflow happens?

@ChrisJar
Copy link
Contributor Author

ChrisJar commented May 21, 2021

Yep good point. When the underlying int value of the result exceeds MAX_INT64 it overflows. However if it exceeds 999,999,999,999,999,999, but is less than MAX_INT64 it will produce a value with a precision of 19.

@ttnghia ttnghia added non-breaking Non-breaking change bug Something isn't working labels May 27, 2021
@harrism
Copy link
Member

harrism commented May 27, 2021

Yep good point. When the underlying int value of the result exceeds MAX_INT64 it overflows. However if it exceeds 999,999,999,999,999,999, but is less than MAX_INT64 it will produce a value with a precision of 19.

So are changes needed on this PR, or is it ready to merge?

@ChrisJar
Copy link
Contributor Author

@harrism Yep! It's ready to merge

@harrism
Copy link
Member

harrism commented May 27, 2021

@gpucibot merge

@rapids-bot rapids-bot bot merged commit 7231e3b into rapidsai:branch-21.06 May 27, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working non-breaking Non-breaking change Python Affects Python cuDF API.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG] Binary ops between decimals with high precisions fail
5 participants