Skip to content

Conversation

@ccarpentiere
Copy link
Contributor

@ccarpentiere ccarpentiere commented Dec 11, 2025

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

  • Yes, merge this PR after it is approved
  • No, don't merge this PR after it is approved

Style

Testing

Intended location

API enablement

  • If the sample needs an API enabled to pass testing, I have added the service to the Test setup file

Review

  • If this sample adds a new directory, I have added codeowners to the CODEOWNERS file

@ccarpentiere ccarpentiere requested review from a team as code owners December 11, 2025 23:17
@snippet-bot
Copy link

snippet-bot bot commented Dec 11, 2025

Here is the summary of changes.

You are about to add 1 region tag.

This comment is generated by snippet-bot.
If you find problems with this result, please file an issue at:
https://github.com/googleapis/repo-automation-bots/issues.
To update this comment, add snippet-bot:force-run label or use the checkbox below:

  • Refresh this comment


# [START bigquery_query]
resource "google_bigquery_job" "my_query_job" {
job_id = "my_query_job"
Copy link
Contributor

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.

Copy link
Contributor Author

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.

Copy link
Contributor

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;"
Copy link
Contributor

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.

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

Successfully merging this pull request may close these issues.

2 participants