我在一个R ipython笔记本上工作(相对R新手),并试图使用'bigrquery‘从Google Big Query中提取数据。有人告诉我这应该很简单,但是使用标准sql进行提取是行不通的。
下面是我的代码:
require("bigrquery")
# Use your project ID here
project <- "project-id" # put your project ID here
standard_sql <- "SELECT year, month, day, weight_pounds FROM `publicdata.samples.natality` LIMIT 5"
legacy_sql <- "SELECT year, month, day, weight_pounds FROM [publicdata:samples.natality] LIMIT 5"
# doesn't work
standard_data <- query_exec(standard_sql, project = project, useLegacySql = FALSE)
# works
legacy_data <- query_exec(legacy_sql, project = project, useLegacySql = TRUE)对于上面的标准sql,它返回以下错误:
Error: Invalid table name: `publicdata:samples.natality`
Traceback:
1. query_exec(standard_sql, project = project, useLegacySql = FALSE)
2. run_query_job(query = query, project = project, destination_table = destination_table,
. default_dataset = default_dataset, create_disposition = create_disposition,
. write_disposition = write_disposition, use_legacy_sql = use_legacy_sql,
. quiet = quiet, ...)
3. wait_for(job, quiet = quiet)
4. stop(err$message, call. = FALSE)这表明我没有为标准SQL输入正确的表名,但我似乎输入了正确的表名,并且查询在GBQ控制台上运行良好。
出什么问题了?
发布于 2017-07-27 00:08:50
您向函数发送了错误的变量。
应该是use_legacy_sql = FALSE而不是useLegacySql。他们在提交新代码后立即changed变量名。
https://stackoverflow.com/questions/45331678
复制相似问题