Unable to use bigrquery with standard sql

依然范特西╮ 提交于 2019-12-13 16:23:53

问题


I'm working in an R ipython notebook (relative R newbie) and trying to extract data from Google Big Query using 'bigrquery'. I'm told this should be simple, but extracting using standard sql isn't working.

Here's my code:

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)

For the standard sql above it returns the following error:

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)

It's suggesting that I've not entered the table name correctly for standard SQL, but I seemingly have and the query runs fine from the GBQ console.

What's going wrong?


回答1:


You sent the wrong variable to the function.

It should be use_legacy_sql = FALSE instead of useLegacySql. They changed the variable name right after committing the new code.



来源:https://stackoverflow.com/questions/45331678/unable-to-use-bigrquery-with-standard-sql

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!