Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix bqr_grant_extract_access vignette example #44

Open
LePeti opened this issue Jan 5, 2018 · 1 comment
Open

Fix bqr_grant_extract_access vignette example #44

LePeti opened this issue Jan 5, 2018 · 1 comment

Comments

@LePeti
Copy link

LePeti commented Jan 5, 2018

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, "your@email.com")

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), "your@email.com")

> 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
@MarkEdmondson1234
Copy link
Collaborator

Thanks! Will update as per your example.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants