4
votes

I've recently started using "bigrquery" package in R to get some data from Google Bigquery, however most of the integer columns in the data frame I receive has NAs.

The same SQL query in Google's own BigQuery dashboard returns valid results. I also tried in python and the same query returns valid results there as well so it's really R-specific (it's not an authorization problem).

What I receive when I call query_exec(query,project=projectID) in R:

R result

What I receive in Google BigQuery or call pd.io.gbq.read_gbq(query,projectID) in Python:

BQ_python result

What could be the reason?

Error message I receive for these NAs is:

NAs introduced by coercion to integer range

1

1 Answers

4
votes

I'm not familiar with R or "bigrquery" specifically, but it sounds like your integer values are being coerced into a 32-bit integer and are out-of-range (BigQuery integers are 64-bit).

Workaround: if you just want to treat the number as an opaque ID, can you cast it to a string in your query?

It isn't clear to me why the same thing would happen for your boolean column, but perhaps you should check that the types are equivalent (maybe integer vs. boolean), since they seem to work for the following column.

Possibly related: https://github.com/rstats-db/bigrquery/issues/35