Skip to content

Commit e41ed8a

Browse files
authored
doc(bigquery): uncomment Client constructor and imports in samples (#10058)
* doc(bigquery): uncomment Client constructor in samples Use a session-scope filter to ensure that a client is only constructed once per test run, saving time on authentication. * remove unnecessary TODOs * add drive scope to credentials
1 parent d81158c commit e41ed8a

File tree

119 files changed

+403
-397
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

119 files changed

+403
-397
lines changed

bigquery/samples/add_empty_column.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@
1313
# limitations under the License.
1414

1515

16-
def add_empty_column(client, table_id):
16+
def add_empty_column(table_id):
1717

1818
# [START bigquery_add_empty_column]
1919
from google.cloud import bigquery
2020

21-
# TODO(developer): Construct a BigQuery client object.
22-
# client = bigquery.Client()
21+
# Construct a BigQuery client object.
22+
client = bigquery.Client()
2323

2424
# TODO(developer): Set table_id to the ID of the table
2525
# to add an empty column.

bigquery/samples/browse_table_data.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,14 @@
1313
# limitations under the License.
1414

1515

16-
def browse_table_data(client, table_id):
16+
def browse_table_data(table_id):
1717

1818
# [START bigquery_browse_table]
19-
# TODO(developer): Import the client library.
20-
# from google.cloud import bigquery
2119

22-
# TODO(developer): Construct a BigQuery client object.
23-
# client = bigquery.Client()
20+
from google.cloud import bigquery
21+
22+
# Construct a BigQuery client object.
23+
client = bigquery.Client()
2424

2525
# TODO(developer): Set table_id to the ID of the table to browse data rows.
2626
# table_id = "your-project.your_dataset.your_table_name"

bigquery/samples/client_list_jobs.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,16 @@
1313
# limitations under the License.
1414

1515

16-
def client_list_jobs(client):
16+
def client_list_jobs():
1717

1818
# [START bigquery_list_jobs]
19-
# TODO(developer): Import the client library.
20-
# from google.cloud import bigquery
19+
20+
from google.cloud import bigquery
2121

2222
import datetime
2323

24-
# TODO(developer): Construct a BigQuery client object.
25-
# client = bigquery.Client()
24+
# Construct a BigQuery client object.
25+
client = bigquery.Client()
2626

2727
# List the 10 most recent jobs in reverse chronological order.
2828
# Omit the max_results parameter to list jobs from the past 6 months.

bigquery/samples/client_load_partitioned_table.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@
1313
# limitations under the License.
1414

1515

16-
def client_load_partitioned_table(client, table_id):
16+
def client_load_partitioned_table(table_id):
1717

1818
# [START bigquery_load_table_partitioned]
1919
from google.cloud import bigquery
2020

21-
# TODO(developer): Construct a BigQuery client object.
22-
# client = bigquery.Client()
21+
# Construct a BigQuery client object.
22+
client = bigquery.Client()
2323

2424
# TODO(developer): Set table_id to the ID of the table to create.
2525
# table_id = "your-project.your_dataset.your_table_name"

bigquery/samples/client_query.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,14 @@
1313
# limitations under the License.
1414

1515

16-
def client_query(client):
16+
def client_query():
1717

1818
# [START bigquery_query]
19-
# TODO(developer): Import the client library.
20-
# from google.cloud import bigquery
2119

22-
# TODO(developer): Construct a BigQuery client object.
23-
# client = bigquery.Client()
20+
from google.cloud import bigquery
21+
22+
# Construct a BigQuery client object.
23+
client = bigquery.Client()
2424

2525
query = """
2626
SELECT name, SUM(number) as total_people

bigquery/samples/client_query_add_column.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@
1313
# limitations under the License.
1414

1515

16-
def client_query_add_column(client, table_id):
16+
def client_query_add_column(table_id):
1717

1818
# [START bigquery_add_column_query_append]
1919
from google.cloud import bigquery
2020

21-
# TODO(developer): Construct a BigQuery client object.
22-
# client = bigquery.Client()
21+
# Construct a BigQuery client object.
22+
client = bigquery.Client()
2323

2424
# TODO(developer): Set table_id to the ID of the destination table.
2525
# table_id = "your-project.your_dataset.your_table_name"

bigquery/samples/client_query_batch.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@
1313
# limitations under the License.
1414

1515

16-
def client_query_batch(client):
16+
def client_query_batch():
1717

1818
# [START bigquery_query_batch]
1919
from google.cloud import bigquery
2020

21-
# TODO(developer): Construct a BigQuery client object.
22-
# client = bigquery.Client()
21+
# Construct a BigQuery client object.
22+
client = bigquery.Client()
2323

2424
job_config = bigquery.QueryJobConfig(
2525
# Run at batch priority, which won't count toward concurrent rate limit.

bigquery/samples/client_query_destination_table.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@
1313
# limitations under the License.
1414

1515

16-
def client_query_destination_table(client, table_id):
16+
def client_query_destination_table(table_id):
1717

1818
# [START bigquery_query_destination_table]
1919
from google.cloud import bigquery
2020

21-
# TODO(developer): Construct a BigQuery client object.
22-
# client = bigquery.Client()
21+
# Construct a BigQuery client object.
22+
client = bigquery.Client()
2323

2424
# TODO(developer): Set table_id to the ID of the destination table.
2525
# table_id = "your-project.your_dataset.your_table_name"

bigquery/samples/client_query_destination_table_cmek.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@
1313
# limitations under the License.
1414

1515

16-
def client_query_destination_table_cmek(client, table_id, kms_key_name):
16+
def client_query_destination_table_cmek(table_id, kms_key_name):
1717

1818
# [START bigquery_query_destination_table_cmek]
1919
from google.cloud import bigquery
2020

21-
# TODO(developer): Construct a BigQuery client object.
22-
# client = bigquery.Client()
21+
# Construct a BigQuery client object.
22+
client = bigquery.Client()
2323

2424
# TODO(developer): Set table_id to the ID of the destination table.
2525
# table_id = "your-project.your_dataset.your_table_name"

bigquery/samples/client_query_destination_table_legacy.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@
1313
# limitations under the License.
1414

1515

16-
def client_query_destination_table_legacy(client, table_id):
16+
def client_query_destination_table_legacy(table_id):
1717

1818
# [START bigquery_query_legacy_large_results]
1919
from google.cloud import bigquery
2020

21-
# TODO(developer): Construct a BigQuery client object.
22-
# client = bigquery.Client()
21+
# Construct a BigQuery client object.
22+
client = bigquery.Client()
2323

2424
# TODO(developer): Set table_id to the ID of the destination table.
2525
# table_id = "your-project.your_dataset.your_table_name"

0 commit comments

Comments
 (0)