Skip to content

Commit 915aaa4

Browse files
committed
docs(bigquery): remove location parameter from samples
The parameter can sometimes confuse new BigQuery developers. Since location autodetection now works pretty well, the parameter can be removed from code samples for better clarity, except where the samples want to explicitly demonstrate its usage.
1 parent 1ab9eb7 commit 915aaa4

14 files changed

+12
-50
lines changed

bigquery/samples/client_query.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,7 @@ def client_query(client):
3030
ORDER BY total_people DESC
3131
LIMIT 20
3232
"""
33-
query_job = client.query(
34-
query,
35-
location="US", # Must match the source and the destination dataset(s) location.
36-
) # Make an API request.
33+
query_job = client.query(query) # Make an API request.
3734

3835
print("The query data:")
3936
for row in query_job:

bigquery/samples/client_query_add_column.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ def client_query_add_column(client, table_id):
4343
# 'age' columns, while the results of this query will contain an
4444
# additional 'favorite_color' column.
4545
'SELECT "Timmy" as full_name, 85 as age, "Blue" as favorite_color;',
46-
location="US", # Must match the source and the destination dataset(s) location.
4746
job_config=job_config,
4847
) # Make an API request.
4948
query_job.result() # Wait for the job to complete.

bigquery/samples/client_query_batch.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,11 @@ def client_query_batch(client):
3232
"""
3333

3434
# Start the query, passing in the extra configuration.
35-
query_job = client.query(
36-
sql, location="US", job_config=job_config
37-
) # Make an API request.
35+
query_job = client.query(sql, job_config=job_config) # Make an API request.
3836

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

4341
print("Job {} is currently in state {}".format(query_job.job_id, query_job.state))
4442
# [END bigquery_query_batch]

bigquery/samples/client_query_destination_table.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,7 @@ def client_query_destination_table(client, table_id):
3535
"""
3636

3737
# Start the query, passing in the extra configuration.
38-
query_job = client.query(
39-
sql,
40-
location="US", # Must match the source and the destination dataset(s) location.
41-
job_config=job_config,
42-
) # Make an API request.
38+
query_job = client.query(sql, job_config=job_config) # Make an API request.
4339
query_job.result() # Wait for the job to complete.
4440

4541
print("Query results loaded to the table {}".format(table_id))

bigquery/samples/client_query_destination_table_cmek.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,7 @@ def client_query_destination_table_cmek(client, table_id, kms_key_name):
3838

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

bigquery/samples/client_query_destination_table_legacy.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,7 @@ def client_query_destination_table_legacy(client, table_id):
4040
"""
4141

4242
# Start the query, passing in the extra configuration.
43-
query_job = client.query(
44-
sql,
45-
location="US", # Must match the source and the destination dataset(s) location.
46-
job_config=job_config,
47-
) # Make an API request.
43+
query_job = client.query(sql, job_config=job_config) # Make an API request.
4844
query_job.result() # Wait for the job to complete.
4945

5046
print("Query results loaded to the table {}".format(table_id))

bigquery/samples/client_query_dry_run.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ def client_query_dry_run(client):
3333
"WHERE state = 'WA' "
3434
"GROUP BY name"
3535
),
36-
location="US", # Must match the source and the destination dataset(s) location.
3736
job_config=job_config,
3837
) # Make an API request.
3938

bigquery/samples/client_query_legacy_sql.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,7 @@ def client_query_legacy_sql(client):
3232
job_config.use_legacy_sql = True
3333

3434
# Start the query, passing in the extra configuration.
35-
query_job = client.query(
36-
query,
37-
location="US", # Must match the source and the destination dataset(s) location.
38-
job_config=job_config,
39-
) # Make an API request.
35+
query_job = client.query(query, job_config=job_config) # Make an API request.
4036

4137
print("The query data:")
4238
for row in query_job:

bigquery/samples/client_query_relax_column.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ def client_query_relax_column(client, table_id):
4545
# In this example, the existing table contains 'full_name' and 'age' as
4646
# required columns, but the query results will omit the second column.
4747
'SELECT "Beyonce" as full_name;',
48-
location="US", # Must match the source and the destination dataset(s) location.
4948
job_config=job_config,
5049
) # Make an API request.
5150
query_job.result() # Wait for the job to complete.

bigquery/samples/copy_table.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,7 @@ def copy_table(client, source_table_id, destination_table_id):
2828
# TODO(developer): Set destination_table_id to the ID of the destination table.
2929
# destination_table_id = "your-project.destination_dataset.destination_table"
3030

31-
job = client.copy_table(
32-
source_table_id,
33-
destination_table_id,
34-
location="US", # Must match the source and the destination dataset(s) location.
35-
)
31+
job = client.copy_table(source_table_id, destination_table_id)
3632
job.result() # Wait for the job to complete.
3733

3834
print("A copy of the table created.")

0 commit comments

Comments
 (0)