在通过 API 通过 R 从 BigQuery 查询数据时,有没有比将它们转换为字符串更好的方法来处理大整数?
这是一个 MVE,显示整数显示为“NA”的问题:
> library(bigrquery)
>
> bq_str <- "
+ SELECT
+ 206932402797274623 AS big_pk
+ ,SAFE_CAST(206932402797274623 AS string) AS string_pk
+ "
>
> my_df <- bigrquery::query_exec(query = bq_str,
+ project = 'XXXXXXXXXXX',
+ use_legacy_sql = FALSE,
+ bigint = "integer64")
0 bytes processed
Warning message:
In converter[[type]](data_m[i, ]) :
NAs introduced by coercion to integer range
> head(my_df)
big_pk string_pk
1 NA 206932402797274623
这是代码:
library(bigrquery)
bq_str <- "
SELECT
206932402797274623 AS big_pk
,SAFE_CAST(206932402797274623 AS string) AS string_pk
"
my_df <- bigrquery::query_exec(query = bq_str,
project = 'XXXXXX',
use_legacy_sql = FALSE,
bigint = "integer64")
head(my_df)
我正在使用 1.1.1 版bigrquery
。