bigQueryR icon indicating copy to clipboard operation
bigQueryR copied to clipboard

Fix bqr_grant_extract_access vignette example

Open LePeti opened this issue 7 years ago • 1 comments

In the vignette under the Asynchronous Queries paragraph the bqr_grant_extract_access example is incorrect. It says:

## Create the data extract from BigQuery to Cloud Storage
job_extract <- bqr_extract_data("your_project",
                                "your_dataset",
                                "bigResultTable",
                                "your_cloud_storage_bucket_name")
                                
## poll the extract job to check its status
## its done when job$status$state == "DONE"
bqr_get_job("your_project", job_extract$jobReference$jobId)

## to download via a URL and not logging in via Google Cloud Storage interface:
## Use an email that is Google account enabled
## Requires scopes:
##  https://www.googleapis.com/auth/devstorage.full_control
##  https://www.googleapis.com/auth/cloud-platform
## set via options("bigQueryR.scopes") and reauthenticate if needed

download_url <- bqr_grant_extract_access(job_extract, "[email protected]")

The issue is with the last line: the job_extract variable's ProjectID is RUNNING, which won't change to DONE even after the job is actually done.

> job_extract
==Google BigQuery Job==
JobID:           job_ovhibn_6GQBXELWsHOzYTEXXXXXX
ProjectID:       XXXX
Status:          RUNNING 
User:            XXXX
Created:         2018-01-05 15:46:17 
Start:           2018-01-05 15:46:17 
End:              
## View job configuration via job$configuration

To fix this, use the following code snippet instead: download_url <- bqr_grant_extract_access(bqr_wait_for_job(job_extract), "[email protected]")

> bqr_wait_for_job(job_extract)
2018-01-05 15:57:14 -- Waiting for job: job_ovhibn_6GQBXELWsHOzYTEXXXXXX - Job timer: 5.001426 secs
2018-01-05 15:57:15 -- Job status: DONE
==Google BigQuery Job==
JobID:           job_ovhibn_6GQBXELWsHOzYTEXXXXXX 
ProjectID:       XXXX 
Status:          DONE 
User:            XXXX
Created:         2018-01-05 15:46:17 
Start:           2018-01-05 15:46:17 
End:             2018-01-05 15:46:18 
## View job configuration via job$configuration

LePeti avatar Jan 05 '18 14:01 LePeti

Thanks! Will update as per your example.

MarkEdmondson1234 avatar Jan 05 '18 15:01 MarkEdmondson1234