-
Notifications
You must be signed in to change notification settings - Fork 286
feat(bigquery): Add example for running a query job #912
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
base: main
Are you sure you want to change the base?
feat(bigquery): Add example for running a query job #912
Conversation
|
Here is the summary of changes. You are about to add 1 region tag.
This comment is generated by snippet-bot.
|
|
|
||
| # [START bigquery_query] | ||
| resource "google_bigquery_job" "my_query_job" { | ||
| job_id = "my_query_job" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure you want to actually include job_id here. I see it's used in the example, but I haven't tried this out. If I look at the rest resource it's definitely not including something for query about the job_id. I suspect it might work once but if you ran it again it would fail. I think if you remove it, it will consistently work, but I could be wrong.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Job ID is required. Agreed, you can't re-run without iterating on the job ID. Looks like maybe I could use https://registry.terraform.io/providers/hashicorp/random/latest/docs/resources/uuid to generate a unique ID? Let me give that a try.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool, that would be helpful. Thank you!
| job_id = "my_query_job" | ||
|
|
||
| query { | ||
| query = "SELECT name, SUM(number) AS total FROM `bigquery-public-data.usa_names.usa_1910_2013` GROUP BY name ORDER BY total DESC LIMIT 10;" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
minor nit: the other samples have slightly different SQL, the majority do a LIMIT 100 so would be helpful to do the same here.
Description
NOTE: The region name in this sample looks non-standard, but is used to map to the region name used by the parallel samples in https://docs.cloud.google.com/bigquery/docs/samples/bigquery-query
Fixes #467779271
Note: If you are not associated with Google, open an issue for discussion before submitting a pull request.
Checklist
Readiness
Style
guide
Testing
I have performed tests described in the Contributing guide:
terraform applyterraform fmtcheckIntended location
Yes, this sample will be (or already is) included on cloud.google.com
Location(s): https://docs.cloud.google.com/bigquery/docs/running-queries
No, this sample won't be included on cloud.google.com
Reason:
API enablement
Review