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 #9495

Merged
merged 18 commits into from
Dec 2, 2019

Conversation

emar-kar
Copy link
Contributor

@emar-kar emar-kar commented Oct 18, 2019

Towards #8989
Closes #9499.

List of changes:

New samples:

  1. client_query_add_column;
  2. client_query_batch;
  3. client_query_destination_table;
  4. client_query_destination_table_cmek;
  5. client_query_destination_table_legacy;
  6. client_query_dry_run;
  7. client_query_legacy_sql;
  8. client_query_relax_column;
  9. copy_table_cmek;
  10. copy_table_multiple_source.

Comment lines in samples unified:

  1. client_query;
  2. copy_table;
  3. load_table_dataframe.

DEPRECATED tests

  1. test_create_routine;
  2. test_update_routine;
  3. test_get_routine;
  4. test_delete_routine;
  5. test_list_routines;
  6. test_create_routine_ddl

All those tests were united in the test_routine_samples file!

@emar-kar emar-kar added the api: bigquery Issues related to the BigQuery API. label Oct 18, 2019
@googlebot googlebot added the cla: yes This human has signed the Contributor License Agreement. label Oct 18, 2019
@emar-kar emar-kar changed the title New samples refactor(bigquery): update code samples to use strings for table and dataset IDs Oct 18, 2019
@emar-kar emar-kar requested a review from tswast October 18, 2019 11:01
@emar-kar emar-kar marked this pull request as ready for review October 18, 2019 11:01
@emar-kar emar-kar requested a review from a team October 18, 2019 11:01
@emar-kar emar-kar added the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Oct 18, 2019
@yoshi-kokoro yoshi-kokoro removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Oct 18, 2019
@tswast tswast added the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Oct 18, 2019
@yoshi-kokoro yoshi-kokoro removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Oct 18, 2019
bigquery/samples/copy_table_multiple_source.py Outdated Show resolved Hide resolved
bigquery/samples/copy_table_multiple_source.py Outdated Show resolved Hide resolved
bigquery/samples/copy_table_cmek.py Outdated Show resolved Hide resolved
bigquery/samples/copy_table_cmek.py Outdated Show resolved Hide resolved
bigquery/samples/client_query_legacy_sql.py Outdated Show resolved Hide resolved
bigquery/samples/client_query_destination_table_cmek.py Outdated Show resolved Hide resolved
bigquery/samples/tests/test_client_query_dry_run.py Outdated Show resolved Hide resolved
emar-kar and others added 4 commits October 24, 2019 13:32
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.
@googlebot
Copy link

All (the pull request submitter and all commit authors) CLAs are signed, but one or more commits were authored or co-authored by someone other than the pull request submitter.

We need to confirm that all authors are ok with their commits being contributed to this project. Please have them confirm that by leaving a comment that contains only @googlebot I consent. in this pull request.

Note to project maintainer: There may be cases where the author cannot leave a comment, or the comment is not properly detected as consent. In those cases, you can manually confirm consent of the commit author(s), and set the cla label to yes (if enabled on your project).

ℹ️ Googlers: Go here for more info.

@googlebot googlebot added cla: no This human has *not* signed the Contributor License Agreement. and removed cla: yes This human has signed the Contributor License Agreement. labels Oct 25, 2019
@plamut
Copy link
Contributor

plamut commented Oct 25, 2019

@googlebot I consent.

@googlebot
Copy link

CLAs look good, thanks!

ℹ️ Googlers: Go here for more info.

@googlebot googlebot added cla: yes This human has signed the Contributor License Agreement. and removed cla: no This human has *not* signed the Contributor License Agreement. labels Oct 25, 2019
bigquery/samples/copy_table_cmek.py Outdated Show resolved Hide resolved
bigquery/samples/client_query_destination_table_legacy.py Outdated Show resolved Hide resolved
bigquery/samples/client_query_destination_table_legacy.py Outdated Show resolved Hide resolved
bigquery/samples/client_query_legacy_sql.py Outdated Show resolved Hide resolved
bigquery/samples/client_query_destination_table.py Outdated Show resolved Hide resolved
bigquery/samples/client_query_destination_table.py Outdated Show resolved Hide resolved
bigquery/samples/client_query_batch.py Outdated Show resolved Hide resolved
bigquery/samples/client_query_relax_column.py Show resolved Hide resolved
@emar-kar emar-kar added the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Nov 8, 2019
@yoshi-kokoro yoshi-kokoro removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Nov 8, 2019
@tswast tswast self-requested a review November 13, 2019 01:17

copy_table_multiple_source.copy_table_multiple_source(
client, random_table_id, table_ids
)
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's call dest_table = client.get_table(random_table_id) and then assert dest_table.num_rows > 0 so that we know that the job did what we expected it to do.



def test_get_routine(capsys, client, routine_id):
def test_client_query_destination_table_legacy(capsys, client, table_id):
Copy link
Contributor

Choose a reason for hiding this comment

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

Use random_table_id since we want to create a new table in the actual sample.

The table_id creates a table before the tests run.

table = client.create_table(table)

assert routine.body == "x * 4"
query_job = client_query_dry_run.client_query_dry_run(client)
out, err = capsys.readouterr()
assert "This query will process 0 bytes." not in out
Copy link
Contributor

Choose a reason for hiding this comment

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

I got confused by this test.

I'd very much like to see a positive assertion that a non-zero number is present. not in could happen for many different reasons.

Suggested change
assert "This query will process 0 bytes." not in out
assert "This query will process" in out
assert query_job.total_bytes_processed > 0

@tswast tswast self-requested a review December 2, 2019 15:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: bigquery Issues related to the BigQuery API. cla: yes This human has signed the Contributor License Agreement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

BigQuery: Remove location parameter from query code samples
5 participants