2017-07-26 48 views
1

我正在R ipython笔记本(相对R新手)中工作,并试图使用'bigrquery'从Google Big Query中提取数据。我被告知这应该很简单,但使用标准的SQL解压缩不起作用。无法使用bigrquery与标准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控制台查询运行良好。

怎么回事?

+0

以防万一 - 在所有小字符中尝试使用false –

+0

为您安装了哪种版本的bigrquery?你能为我们打印packageVersion(“bigrquery”)的结果吗? –

+0

小字错误没有工作 - 版本是'0.4.1' - 是旧的一个有什么机会? – goose

回答

2

您向函数发送了错误的变量。

它应该是use_legacy_sql = FALSE而不是useLegacySql。他们changed提交新代码后的变量名称。

+0

它必须是这样的。非常感谢你们的帮助! – goose