nbenn commented on issue #1005:
URL: https://github.com/apache/arrow-adbc/issues/1005#issuecomment-1702453048
@paleolimbot I'm happy to tackle the problem of providing the user with
options (and implementing them) for how to handle the int64 type in R on the
adbi side. This is backend agnostic and from a distance I don't see any
problems as the required hooks are already there.
There's an (SQLite-specific) sub-problem here though: An int of any size is
represented as an int64
```r
library(adbcdrivermanager)
con <- adbc_connection_init(
adbc_database_init(adbcsqlite::adbcsqlite(), uri = ":memory:")
)
res <- read_adbc(con, "SELECT 1 AS a, 1234567890123456789 as b")
res$get_schema()$children
#> $a
#> <nanoarrow_schema int64>
#> $ format : chr "l"
#> $ name : chr "a"
#> $ metadata : list()
#> $ flags : int 2
#> $ children : list()
#> $ dictionary: NULL
#>
#> $b
#> <nanoarrow_schema int64>
#> $ format : chr "l"
#> $ name : chr "b"
#> $ metadata : list()
#> $ flags : int 2
#> $ children : list()
#> $ dictionary: NULL
```
Most intuitive from a user's perspective I believe (I might be biased
though) however is something like
```r
str(
DBI::dbGetQuery(
DBI::dbConnect(RSQLite::SQLite(), ":memory:"),
"SELECT 1 AS a, 1234567890123456789 as b"
)
)
#> 'data.frame': 1 obs. of 2 variables:
#> $ a: int 1
#> $ b:integer64 1234567890123456789
```
i.e. int types that fit into the R integer range are returned as such and
only for those which do not, we resort to any of the sub-optimal options like
`bit64::integer64`, double, etc.
I could of course look up max/min values and decide what to do based on that.
@krlmlr I assume this is what RSQLite does, right?
The not-so-nice thing is that this now is a backend-specific behavior. I
might want to do this for SQLite, but probably not for PostgreSQL. An int64 in
PostgreSQL should always go the `bit64::integer64`, double, etc. route
irrespective of value range.
@paleolimbot Do you any ideas for (cheaply) getting information on value
ranges (only when needed) before materializing the data as R object?
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]