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

doc(bigquery): uncomment Client constructor and imports in samples #10058

Merged
merged 3 commits into from
Jan 3, 2020
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
6 changes: 3 additions & 3 deletions bigquery/samples/add_empty_column.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@
# limitations under the License.


def add_empty_column(client, table_id):
def add_empty_column(table_id):

# [START bigquery_add_empty_column]
from google.cloud import bigquery

# TODO(developer): Construct a BigQuery client object.
# client = bigquery.Client()
# Construct a BigQuery client object.
client = bigquery.Client()

# TODO(developer): Set table_id to the ID of the table
# to add an empty column.
Expand Down
10 changes: 5 additions & 5 deletions bigquery/samples/browse_table_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@
# limitations under the License.


def browse_table_data(client, table_id):
def browse_table_data(table_id):

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

# TODO(developer): Construct a BigQuery client object.
# client = bigquery.Client()
from google.cloud import bigquery

# Construct a BigQuery client object.
client = bigquery.Client()

# TODO(developer): Set table_id to the ID of the table to browse data rows.
# table_id = "your-project.your_dataset.your_table_name"
Expand Down
10 changes: 5 additions & 5 deletions bigquery/samples/client_list_jobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,16 @@
# limitations under the License.


def client_list_jobs(client):
def client_list_jobs():

# [START bigquery_list_jobs]
# TODO(developer): Import the client library.
# from google.cloud import bigquery

from google.cloud import bigquery

import datetime

# TODO(developer): Construct a BigQuery client object.
# client = bigquery.Client()
# Construct a BigQuery client object.
client = bigquery.Client()

# List the 10 most recent jobs in reverse chronological order.
# Omit the max_results parameter to list jobs from the past 6 months.
Expand Down
6 changes: 3 additions & 3 deletions bigquery/samples/client_load_partitioned_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@
# limitations under the License.


def client_load_partitioned_table(client, table_id):
def client_load_partitioned_table(table_id):

# [START bigquery_load_table_partitioned]
from google.cloud import bigquery

# TODO(developer): Construct a BigQuery client object.
# client = bigquery.Client()
# Construct a BigQuery client object.
client = bigquery.Client()

# TODO(developer): Set table_id to the ID of the table to create.
# table_id = "your-project.your_dataset.your_table_name"
Expand Down
10 changes: 5 additions & 5 deletions bigquery/samples/client_query.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@
# limitations under the License.


def client_query(client):
def client_query():

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

# TODO(developer): Construct a BigQuery client object.
# client = bigquery.Client()
from google.cloud import bigquery

# Construct a BigQuery client object.
client = bigquery.Client()

query = """
SELECT name, SUM(number) as total_people
Expand Down
6 changes: 3 additions & 3 deletions bigquery/samples/client_query_add_column.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@
# limitations under the License.


def client_query_add_column(client, table_id):
def client_query_add_column(table_id):

# [START bigquery_add_column_query_append]
from google.cloud import bigquery

# TODO(developer): Construct a BigQuery client object.
# client = bigquery.Client()
# Construct a BigQuery client object.
client = bigquery.Client()

# TODO(developer): Set table_id to the ID of the destination table.
# table_id = "your-project.your_dataset.your_table_name"
Expand Down
6 changes: 3 additions & 3 deletions bigquery/samples/client_query_batch.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@
# limitations under the License.


def client_query_batch(client):
def client_query_batch():

# [START bigquery_query_batch]
from google.cloud import bigquery

# TODO(developer): Construct a BigQuery client object.
# client = bigquery.Client()
# Construct a BigQuery client object.
client = bigquery.Client()

job_config = bigquery.QueryJobConfig(
# Run at batch priority, which won't count toward concurrent rate limit.
Expand Down
6 changes: 3 additions & 3 deletions bigquery/samples/client_query_destination_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@
# limitations under the License.


def client_query_destination_table(client, table_id):
def client_query_destination_table(table_id):

# [START bigquery_query_destination_table]
from google.cloud import bigquery

# TODO(developer): Construct a BigQuery client object.
# client = bigquery.Client()
# Construct a BigQuery client object.
client = bigquery.Client()

# TODO(developer): Set table_id to the ID of the destination table.
# table_id = "your-project.your_dataset.your_table_name"
Expand Down
6 changes: 3 additions & 3 deletions bigquery/samples/client_query_destination_table_cmek.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@
# limitations under the License.


def client_query_destination_table_cmek(client, table_id, kms_key_name):
def client_query_destination_table_cmek(table_id, kms_key_name):

# [START bigquery_query_destination_table_cmek]
from google.cloud import bigquery

# TODO(developer): Construct a BigQuery client object.
# client = bigquery.Client()
# Construct a BigQuery client object.
client = bigquery.Client()

# TODO(developer): Set table_id to the ID of the destination table.
# table_id = "your-project.your_dataset.your_table_name"
Expand Down
6 changes: 3 additions & 3 deletions bigquery/samples/client_query_destination_table_legacy.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@
# limitations under the License.


def client_query_destination_table_legacy(client, table_id):
def client_query_destination_table_legacy(table_id):

# [START bigquery_query_legacy_large_results]
from google.cloud import bigquery

# TODO(developer): Construct a BigQuery client object.
# client = bigquery.Client()
# Construct a BigQuery client object.
client = bigquery.Client()

# TODO(developer): Set table_id to the ID of the destination table.
# table_id = "your-project.your_dataset.your_table_name"
Expand Down
6 changes: 3 additions & 3 deletions bigquery/samples/client_query_dry_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@
# limitations under the License.


def client_query_dry_run(client):
def client_query_dry_run():

# [START bigquery_query_dry_run]
from google.cloud import bigquery

# TODO(developer): Construct a BigQuery client object.
# client = bigquery.Client()
# Construct a BigQuery client object.
client = bigquery.Client()

job_config = bigquery.QueryJobConfig(dry_run=True, use_query_cache=False)

Expand Down
6 changes: 3 additions & 3 deletions bigquery/samples/client_query_legacy_sql.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@
# limitations under the License.


def client_query_legacy_sql(client):
def client_query_legacy_sql():

# [START bigquery_query_legacy]
from google.cloud import bigquery

# TODO(developer): Construct a BigQuery client object.
# client = bigquery.Client()
# Construct a BigQuery client object.
client = bigquery.Client()

query = (
"SELECT name FROM [bigquery-public-data:usa_names.usa_1910_2013] "
Expand Down
6 changes: 3 additions & 3 deletions bigquery/samples/client_query_relax_column.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@
# limitations under the License.


def client_query_relax_column(client, table_id):
def client_query_relax_column(table_id):

# [START bigquery_relax_column_query_append]
from google.cloud import bigquery

# TODO(developer): Construct a BigQuery client object.
# client = bigquery.Client()
# Construct a BigQuery client object.
client = bigquery.Client()

# TODO(developer): Set table_id to the ID of the destination table.
# table_id = "your-project.your_dataset.your_table_name"
Expand Down
6 changes: 3 additions & 3 deletions bigquery/samples/client_query_w_array_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@
# limitations under the License.


def client_query_w_array_params(client):
def client_query_w_array_params():

# [START bigquery_query_params_arrays]
from google.cloud import bigquery

# TODO(developer): Construct a BigQuery client object.
# client = bigquery.Client()
# Construct a BigQuery client object.
client = bigquery.Client()

query = """
SELECT name, sum(number) as count
Expand Down
6 changes: 3 additions & 3 deletions bigquery/samples/client_query_w_named_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@
# limitations under the License.


def client_query_w_named_params(client):
def client_query_w_named_params():

# [START bigquery_query_params_named]
from google.cloud import bigquery

# TODO(developer): Construct a BigQuery client object.
# client = bigquery.Client()
# Construct a BigQuery client object.
client = bigquery.Client()

query = """
SELECT word, word_count
Expand Down
6 changes: 3 additions & 3 deletions bigquery/samples/client_query_w_positional_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@
# limitations under the License.


def client_query_w_positional_params(client):
def client_query_w_positional_params():

# [START bigquery_query_params_positional]
from google.cloud import bigquery

# TODO(developer): Construct a BigQuery client object.
# client = bigquery.Client()
# Construct a BigQuery client object.
client = bigquery.Client()

query = """
SELECT word, word_count
Expand Down
6 changes: 3 additions & 3 deletions bigquery/samples/client_query_w_struct_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@
# limitations under the License.


def client_query_w_struct_params(client):
def client_query_w_struct_params():

# [START bigquery_query_params_structs]
from google.cloud import bigquery

# TODO(developer): Construct a BigQuery client object.
# client = bigquery.Client()
# Construct a BigQuery client object.
client = bigquery.Client()

query = "SELECT @struct_value AS s;"
job_config = bigquery.QueryJobConfig(
Expand Down
6 changes: 3 additions & 3 deletions bigquery/samples/client_query_w_timestamp_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,16 @@
# limitations under the License.


def client_query_w_timestamp_params(client):
def client_query_w_timestamp_params():

# [START bigquery_query_params_timestamps]
import datetime

import pytz
from google.cloud import bigquery

# TODO(developer): Construct a BigQuery client object.
# client = bigquery.Client()
# Construct a BigQuery client object.
client = bigquery.Client()

query = "SELECT TIMESTAMP_ADD(@ts_value, INTERVAL 1 HOUR);"
job_config = bigquery.QueryJobConfig(
Expand Down
10 changes: 5 additions & 5 deletions bigquery/samples/copy_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@
# limitations under the License.


def copy_table(client, source_table_id, destination_table_id):
def copy_table(source_table_id, destination_table_id):

# [START bigquery_copy_table]
# TODO(developer): Import the client library.
# from google.cloud import bigquery

# TODO(developer): Construct a BigQuery client object.
# client = bigquery.Client()
from google.cloud import bigquery

# Construct a BigQuery client object.
client = bigquery.Client()

# TODO(developer): Set source_table_id to the ID of the original table.
# source_table_id = "your-project.source_dataset.source_table"
Expand Down
6 changes: 3 additions & 3 deletions bigquery/samples/copy_table_cmek.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@
# limitations under the License.


def copy_table_cmek(client, dest_table_id, orig_table_id, kms_key_name):
def copy_table_cmek(dest_table_id, orig_table_id, kms_key_name):

# [START bigquery_copy_table_cmek]
from google.cloud import bigquery

# TODO(developer): Construct a BigQuery client object.
# client = bigquery.Client()
# Construct a BigQuery client object.
client = bigquery.Client()

# TODO(developer): Set dest_table_id to the ID of the destination table.
# dest_table_id = "your-project.your_dataset.your_table_name"
Expand Down
10 changes: 5 additions & 5 deletions bigquery/samples/copy_table_multiple_source.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@
# limitations under the License.


def copy_table_multiple_source(client, dest_table_id, table_ids):
def copy_table_multiple_source(dest_table_id, table_ids):

# [START bigquery_copy_table_multiple_source]
# TODO(developer): Import the client library.
# from google.cloud import bigquery

# TODO(developer): Construct a BigQuery client object.
# client = bigquery.Client()
from google.cloud import bigquery

# Construct a BigQuery client object.
client = bigquery.Client()

# TODO(developer): Set dest_table_id to the ID of the destination table.
# dest_table_id = "your-project.your_dataset.your_table_name"
Expand Down
6 changes: 3 additions & 3 deletions bigquery/samples/create_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@
# limitations under the License.


def create_dataset(client, dataset_id):
def create_dataset(dataset_id):

# [START bigquery_create_dataset]
from google.cloud import bigquery

# TODO(developer): Construct a BigQuery client object.
# client = bigquery.Client()
# Construct a BigQuery client object.
client = bigquery.Client()

# TODO(developer): Set dataset_id to the ID of the dataset to create.
# dataset_id = "{}.your_dataset".format(client.project)
Expand Down
Loading