-
Notifications
You must be signed in to change notification settings - Fork 406
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: decimal stat rounding overflow #2975
base: main
Are you sure you want to change the base?
Conversation
ACTION NEEDED delta-rs follows the Conventional Commits specification for release automation. The PR title and description are used as the merge commit message. Please update your PR title and description to match the specification. |
Signed-off-by: Marko Grujic <[email protected]>
2bee4af
to
fbc8626
Compare
if (val.trunc() as i128).to_string().len() > (precision - scale) as usize { | ||
// For normal values with integer parts that get rounded to a number beyond | ||
// the precision - scale range take the next smaller (by magnitude) value | ||
val = f64::from_bits(val.to_bits() - 1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure how performant this is, but the result won't be consistent/parse-able without it.
The actual "round-down" could be done with next_down
once it's stable/delta-rs uses nightly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rtyler would you be ok with having delta-rs use nightly features?
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2975 +/- ##
==========================================
+ Coverage 72.26% 72.28% +0.01%
==========================================
Files 128 128
Lines 40329 40363 +34
Branches 40329 40363 +34
==========================================
+ Hits 29143 29175 +32
+ Misses 9334 9332 -2
- Partials 1852 1856 +4 ☔ View full report in Codecov by Sentry. |
Description
Try to detect the situation where floating point conversion rounds the integer value beyond the valid Decimal(scale, precision) range, and rollback to next smaller value towards 0.0.
Related Issue(s)
Closes #2974
Documentation
None