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

fix(r): Warn for possibly out of range int64 -> double conversions #294

Merged
merged 1 commit into from
Sep 8, 2023

Conversation

paleolimbot
Copy link
Member

It looks like I had left this as a TODO after my initial push to get most conversions implemented. The idea is to warn when converting very large int64/uint64 values to double. This an important case to warn for because double is the default conversion from int64 and values that won't (or might not) roundtrip back to int64 are important to warn about. See #293 implementing a safer conversion.

library(nanoarrow)

array <- as_nanoarrow_array(2^54, schema = na_int64())
convert_array(array, double())
#> Warning in convert_array.default(array, double()): 1 value(s) may have incurred
#> loss of precision in conversion to double()
#> [1] 1.80144e+16

Created on 2023-09-01 with reprex v2.0.2

@codecov-commenter
Copy link

Codecov Report

Merging #294 (d622ff4) into main (65bb552) will decrease coverage by 0.03%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##             main     #294      +/-   ##
==========================================
- Coverage   86.89%   86.87%   -0.03%     
==========================================
  Files          68       65       -3     
  Lines       10450    10107     -343     
==========================================
- Hits         9081     8780     -301     
+ Misses       1369     1327      -42     
Files Changed Coverage Δ
r/src/materialize_dbl.h 100.00% <100.00%> (ø)

... and 3 files with indirect coverage changes

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@paleolimbot paleolimbot merged commit 6ea9d4b into apache:main Sep 8, 2023
13 checks passed
@paleolimbot paleolimbot deleted the r-double-warn-range branch September 19, 2023 20:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants