Skip to content

Commit

Permalink
docs: simplify destination table sample with f-strings (#966)
Browse files Browse the repository at this point in the history
Thank you for opening a Pull Request! Before submitting your PR, there are a few things you can do to make sure it goes smoothly:
- [ ] Make sure to open an issue as a [bug/issue](https://github.com/googleapis/python-bigquery/issues/new/choose) before writing your code!  That way we can discuss the change, evaluate designs, and agree on the general idea
- [ ] Ensure the tests and linter pass
- [ ] Code coverage does not decrease (if any source code was changed)
- [ ] Appropriate docs were updated (if necessary)

Fixes internal issue 199420466 🦕
  • Loading branch information
tswast committed Sep 14, 2021
1 parent 4f72359 commit ab6e76f
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions samples/snippets/natality_tutorial.py
Expand Up @@ -38,28 +38,26 @@ def run_natality_tutorial(override_values={}):

# Prepare a reference to a new dataset for storing the query results.
dataset_id = "natality_regression"
dataset_id_full = "{}.{}".format(client.project, dataset_id)
dataset_id_full = f"{client.project}.{dataset_id}"
# [END bigquery_query_natality_tutorial]
# To facilitate testing, we replace values with alternatives
# provided by the testing harness.
dataset_id = override_values.get("dataset_id", dataset_id)
dataset_id_full = "{}.{}".format(client.project, dataset_id)
dataset_id_full = f"{client.project}.{dataset_id}"
# [START bigquery_query_natality_tutorial]

dataset = bigquery.Dataset(dataset_id_full)

# Create the new BigQuery dataset.
dataset = client.create_dataset(dataset)

# In the new BigQuery dataset, create a reference to a new table for
# storing the query results.
table_ref = dataset.table("regression_input")

# Configure the query job.
job_config = bigquery.QueryJobConfig()

# Set the destination table to the table reference created above.
job_config.destination = table_ref
# Set the destination table to where you want to store query results.
# As of google-cloud-bigquery 1.11.0, a fully qualified table ID can be
# used in place of a TableReference.
job_config.destination = f"{dataset_id_full}.regression_input"

# Set up a query in Standard SQL, which is the default for the BigQuery
# Python client library.
Expand Down

0 comments on commit ab6e76f

Please sign in to comment.