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

64 bit integers not always passed with bigint parameter set to "integer64" or "character" #437

Closed
CartWill opened this issue Mar 23, 2021 · 2 comments

Comments

@CartWill
Copy link

I've been trying to get this to work but the bigint option doesn't appear to work with the tbl dplyr function. Any int64 data types get returned as NAs

Here's an example. This doesn't work to return a 64 bit integer in the result:

> db <- dbConnect(bigrquery::bigquery(), project="hdcohdsicovid19", dataset="omop_covid19_kratos", bigint = "integer64")
> cohort_table_db<-tbl(db, sql("SELECT cast('123456789012345' as int64) as example"))
> cohort_table_db
Complete
Billed: 0 B
Downloading 1 rows in 1 pages.
# Source:   SQL [?? x 1]                                                                                  
# Database: BigQueryConnection
  example
    <int>
1      NA
Warning message:
In as.integer.integer64(x) : NAs produced by integer overflow

but this does:

> db <- dbConnect(bigrquery::bigquery(), project="hdcohdsicovid19", dataset="omop_covid19_kratos", bigint = "integer64")
> cohort_table_db<- DBI::dbGetQuery(db, sql("SELECT cast('123456789012345' as int64) as example"))
Complete
Billed: 0 B
Downloading 1 rows in 1 pages.
> cohort_table_db                                                                                         
# A tibble: 1 x 1
  example
  <int64>
1 1.00e14

The bigint parameter seems like it gets ignored with the tbl function. Is there a better way to force 64 bit integers in to the result?

@cassws
Copy link
Contributor

cassws commented Mar 23, 2021

+1 with this! i noticed the issue in the dbplyr::tbl implementation and raised this in a dbplyr issue: tidyverse/dbplyr#610

I've read back to prior related issues and realize this may be a bigger-picture issue with piecemeal bit64::integer64 support in general. Would it be useful to attempt a PR at this point to increase bit64::integer64 support in bigrquery OR to raise errors when this type of silent coercion happens? (Apologies if this is too repetitive asking here! Just trying to zero in on a solution.)

@cassws
Copy link
Contributor

cassws commented Apr 6, 2021

@CartWill changes in #440 should fix this too! Just tested locally. I wrote the PR focusing on collect() in a pipeline as per #439 but calling the tbl() object (and thus forcing eval) works as well.

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

No branches or pull requests

3 participants