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

docs(bigquery): remove location parameter from samples #73

Merged
merged 2 commits into from
Oct 25, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions bigquery/samples/client_query.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,7 @@ def client_query(client):
ORDER BY total_people DESC
LIMIT 20
"""
query_job = client.query(
query,
location="US", # Must match the source and the destination dataset(s) location.
) # Make an API request.
query_job = client.query(query) # Make an API request.

print("The query data:")
for row in query_job:
Expand Down
1 change: 0 additions & 1 deletion bigquery/samples/client_query_add_column.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ def client_query_add_column(client, table_id):
# 'age' columns, while the results of this query will contain an
# additional 'favorite_color' column.
'SELECT "Timmy" as full_name, 85 as age, "Blue" as favorite_color;',
location="US", # Must match the source and the destination dataset(s) location.
job_config=job_config,
) # Make an API request.
query_job.result() # Wait for the job to complete.
Expand Down
8 changes: 4 additions & 4 deletions bigquery/samples/client_query_batch.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,13 @@ def client_query_batch(client):
"""

# Start the query, passing in the extra configuration.
query_job = client.query(
sql, location="US", job_config=job_config
) # Make an API request.
query_job = client.query(sql, job_config=job_config) # Make an API request.

# Check on the progress by getting the job's updated state. Once the state
# is `DONE`, the results are ready.
query_job = client.get_job(query_job.job_id, location="US") # Make an API request.
query_job = client.get_job(
query_job.job_id, location=query_job.location
) # Make an API request.

print("Job {} is currently in state {}".format(query_job.job_id, query_job.state))
# [END bigquery_query_batch]
Expand Down
6 changes: 1 addition & 5 deletions bigquery/samples/client_query_destination_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,7 @@ def client_query_destination_table(client, table_id):
"""

# Start the query, passing in the extra configuration.
query_job = client.query(
sql,
location="US", # Must match the source and the destination dataset(s) location.
job_config=job_config,
) # Make an API request.
query_job = client.query(sql, job_config=job_config) # Make an API request.
query_job.result() # Wait for the job to complete.

print("Query results loaded to the table {}".format(table_id))
Expand Down
4 changes: 1 addition & 3 deletions bigquery/samples/client_query_destination_table_cmek.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,7 @@ def client_query_destination_table_cmek(client, table_id, kms_key_name):

# Start the query, passing in the extra configuration.
query_job = client.query(
"SELECT 17 AS my_col;",
location="US", # Must match the source and the destination dataset(s) location.
job_config=job_config,
"SELECT 17 AS my_col;", job_config=job_config
) # Make an API request.
query_job.result() # Wait for the job to complete.

Expand Down
6 changes: 1 addition & 5 deletions bigquery/samples/client_query_destination_table_legacy.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,7 @@ def client_query_destination_table_legacy(client, table_id):
"""

# Start the query, passing in the extra configuration.
query_job = client.query(
sql,
location="US", # Must match the source and the destination dataset(s) location.
job_config=job_config,
) # Make an API request.
query_job = client.query(sql, job_config=job_config) # Make an API request.
query_job.result() # Wait for the job to complete.

print("Query results loaded to the table {}".format(table_id))
Expand Down
1 change: 0 additions & 1 deletion bigquery/samples/client_query_dry_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ def client_query_dry_run(client):
"WHERE state = 'WA' "
"GROUP BY name"
),
location="US", # Must match the source and the destination dataset(s) location.
job_config=job_config,
) # Make an API request.

Expand Down
6 changes: 1 addition & 5 deletions bigquery/samples/client_query_legacy_sql.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,7 @@ def client_query_legacy_sql(client):
job_config.use_legacy_sql = True

# Start the query, passing in the extra configuration.
query_job = client.query(
query,
location="US", # Must match the source and the destination dataset(s) location.
job_config=job_config,
) # Make an API request.
query_job = client.query(query, job_config=job_config) # Make an API request.

print("The query data:")
for row in query_job:
Expand Down
1 change: 0 additions & 1 deletion bigquery/samples/client_query_relax_column.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ def client_query_relax_column(client, table_id):
# In this example, the existing table contains 'full_name' and 'age' as
# required columns, but the query results will omit the second column.
'SELECT "Beyonce" as full_name;',
location="US", # Must match the source and the destination dataset(s) location.
job_config=job_config,
) # Make an API request.
query_job.result() # Wait for the job to complete.
Expand Down
6 changes: 1 addition & 5 deletions bigquery/samples/copy_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,7 @@ def copy_table(client, source_table_id, destination_table_id):
# TODO(developer): Set destination_table_id to the ID of the destination table.
# destination_table_id = "your-project.destination_dataset.destination_table"

job = client.copy_table(
source_table_id,
destination_table_id,
location="US", # Must match the source and the destination dataset(s) location.
)
job = client.copy_table(source_table_id, destination_table_id)
job.result() # Wait for the job to complete.

print("A copy of the table created.")
Expand Down
7 changes: 1 addition & 6 deletions bigquery/samples/copy_table_cmek.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,7 @@ def copy_table_cmek(client, dest_table_id, orig_table_id, kms_key_name):
encryption_config = bigquery.EncryptionConfiguration(kms_key_name=kms_key_name)
job_config = bigquery.CopyJobConfig()
job_config.destination_encryption_configuration = encryption_config
job = client.copy_table(
orig_table_id,
dest_table_id,
location="US", # Must match the source and the destination dataset(s) location.
job_config=job_config,
)
job = client.copy_table(orig_table_id, dest_table_id, job_config=job_config)
job.result() # Wait for the job to complete.

dest_table = client.get_table(dest_table_id) # Make an API request.
Expand Down
6 changes: 1 addition & 5 deletions bigquery/samples/copy_table_multiple_source.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,7 @@ def copy_table_multiple_source(client, dest_table_id, table_ids):
# TODO(developer): Set table_ids to the list of the IDs of the original tables.
# table_ids = ["your-project.your_dataset.your_table_name", ...]

job = client.copy_table(
table_ids,
dest_table_id,
location="US", # Must match the source and the destination dataset(s) location.
) # Make an API request.
job = client.copy_table(table_ids, dest_table_id) # Make an API request.
job.result() # Wait for the job to complete.

print("The tables {} have been appended to {}".format(table_ids, dest_table_id))
Expand Down
5 changes: 1 addition & 4 deletions bigquery/samples/load_table_dataframe.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,7 @@ def load_table_dataframe(client, table_id):
)

job = client.load_table_from_dataframe(
dataframe,
table_id,
job_config=job_config,
location="US", # Must match the source and the destination dataset(s) location.
dataframe, table_id, job_config=job_config
) # Make an API request.
job.result() # Wait for the job to complete.

Expand Down
2 changes: 1 addition & 1 deletion bigquery/samples/tests/test_create_job.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@
def test_create_job(capsys, client):

query_job = create_job.create_job(client)
client.cancel_job(query_job.job_id, location="US")
client.cancel_job(query_job.job_id, location=query_job.location)
out, err = capsys.readouterr()
assert "Started job: {}".format(query_job.job_id) in out