You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "paleolimbot (via GitHub)" <gi...@apache.org> on 2023/08/31 20:09:48 UTC
[GitHub] [arrow-adbc] paleolimbot commented on issue #1005: r/adbcsqlite: int type conversion to R
paleolimbot commented on issue #1005:
URL: https://github.com/apache/arrow-adbc/issues/1005#issuecomment-1701714557
We chatted a bit offline about this, but this happens because nanoarrow's default conversion from Arrow's `int64` type is an R `double`. This is potentially a bad choice but was one that I did because (1) you will always get the same answer for `nanoarrow_infer_ptype(some_array_of_integers)`, which matters in the preallocate + fill pattern where you allocate before you know exactly what data you have and (2) because using `bit64::integer64()` requires a dependency (`classInt`) that is a bit heavy and requires a Fortran compiler.
At least in nanoarrow (not in arrow), you can always tell it what R vector type you want back:
``` r
library(nanoarrow)
int64_array <- as_nanoarrow_array(
data.frame(x = 1:5),
schema = na_struct(list(x = na_int64()))
)
str(convert_array_stream(basic_array_stream(list(int64_array))))
#> 'data.frame': 5 obs. of 1 variable:
#> $ x: num 1 2 3 4 5
str(
convert_array_stream(
basic_array_stream(list(int64_array)),
to = data.frame(x = integer())
)
)
#> 'data.frame': 5 obs. of 1 variable:
#> $ x: int 1 2 3 4 5
```
I'm not keen to implement a list of options in nanoarrow or adbcdrivermanager although I get how it may be helpful to temporarily replace the default behaviour of `nanoarrow_infer_ptype()` to give something that is safer (e.g., `integer64()`) or more practical (e.g., `integer()`).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org