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

refactor(bigquery): update code samples to use strings for table and dataset IDs #9974

Merged
merged 16 commits into from
Dec 26, 2019

Conversation

emar-kar
Copy link
Contributor

Towards #8989
Closes #9596

List of changes:

New samples:

  1. load_and_query_partitioned_table;
  2. client_query_w_named_params;
  3. client_query_w_positional_params;
  4. client_query_w_timestamp_params;
  5. client_query_w_array_params;
  6. client_query_w_struct_params;
  7. query_no_cache;
  8. query_external_gcs_temporary_table.

Update existing samples:

  1. remove client_query_legacy_sql from snippets
  2. unify test_update_table_require_partition_filter
  3. Update test_copy_table_multiple_source.py
  4. Update client_query_add_column.py
  5. Update client_query_relax_column.py

@emar-kar emar-kar requested review from tswast and plamut December 13, 2019 14:33
@googlebot googlebot added the cla: yes This human has signed the Contributor License Agreement. label Dec 13, 2019
@emar-kar emar-kar marked this pull request as ready for review December 13, 2019 16:08
@emar-kar emar-kar requested a review from a team December 13, 2019 16:08
Copy link
Contributor

@tswast tswast left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM once a few nits have been addressed.

# [START bigquery_query_partitioned_table]
from google.cloud import bigquery

import datetime
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Import built-in datetime before "third-party" libraries like google-cloud-bigquery.

bigquery/docs/snippets.py Show resolved Hide resolved
# TODO(developer): Construct a BigQuery client object.
# client = bigquery.Client()

import datetime
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Import built-ins in a group before google-cloud-bigquery.

# client = bigquery.Client()

import datetime
import pytz
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Import pytz in same import group as google-cloud-bigquery.

FROM `bigquery-public-data.samples.shakespeare`
GROUP BY corpus;
"""
query_job = client.query(sql, job_config=job_config,) # Make an API request.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: The linter might complain about the trailing comma here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: yes This human has signed the Contributor License Agreement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

BigQuery: refactor bigquery_query_params_* code samples to pass query_parameters to QueryJobConfig constructor
3 participants