BigQuery: Updates samples for BigQuery Beta 2 (do not merge until release)#1178
BigQuery: Updates samples for BigQuery Beta 2 (do not merge until release)#1178
Conversation
tswast
left a comment
There was a problem hiding this comment.
Overall, LGTM. I know you are in class now, so I'll address most of these comments in a new commit to the branch.
| job_name = str(uuid.uuid4()) | ||
| dataset_ref = bigquery_client.dataset(dataset_id) | ||
| table_ref = dataset_ref.table(table_id) | ||
| job_id = str(uuid.uuid4()) |
There was a problem hiding this comment.
job_id is optional now that the client library can generate it, so probably can be removed from this sample
| job_name = str(uuid.uuid4()) | ||
| dataset_ref = bigquery_client.dataset(dataset_id) | ||
| table_ref = dataset_ref.table(table_id) | ||
| job_id = str(uuid.uuid4()) |
There was a problem hiding this comment.
We can remove this job_id generation.
| ] | ||
| job_config = bigquery.QueryJobConfig() | ||
| job_config.query_parameters = query_params | ||
| job_id = str(uuid.uuid4()) |
There was a problem hiding this comment.
We can remove this job_id, too.
| job_id = str(uuid.uuid4()) | ||
| query_job = client.query(query, job_config=job_config, job_id=job_id) | ||
|
|
||
| query_job.result() # Wait for job to complete |
There was a problem hiding this comment.
We should use the return value for result instead of getting the table after this.
| job_id = str(uuid.uuid4()) | ||
| query_job = client.query(query, job_config=job_config, job_id=job_id) | ||
|
|
||
| query_job.result() # Wait for job to complete |
There was a problem hiding this comment.
Use the rows from the return value for result here.
| job_config.query_parameters = query_params | ||
| query_job = client.query(query, job_config=job_config, job_id=job_id) | ||
|
|
||
| query_job.result() # Waits for job to complete |
There was a problem hiding this comment.
Use the return value from result.
| bigquery.ScalarQueryParameter('y', 'STRING', y) | ||
| ) | ||
| ] | ||
| job_id = str(uuid.uuid4()) |
There was a problem hiding this comment.
Let the client library generate the job ID.
| job_config.query_parameters = query_params | ||
| query_job = client.query(query, job_config=job_config, job_id=job_id) | ||
|
|
||
| query_job.result() # Waits for job to complete |
There was a problem hiding this comment.
Use the return value from result.
| for row in destination_table.fetch_data(): | ||
| print(row) | ||
| for row in results: | ||
| print("{}: {}".format(row.title, row.unique_words)) |
There was a problem hiding this comment.
Love it! It's much nicer to show accessing the specific columns in this sample.
bigquery/cloud-client/snippets.py
Outdated
|
|
||
| # Load at most 25 results. | ||
| rows = itertools.islice(table.fetch_data(), 25) | ||
| rows = itertools.islice(bigquery_client.list_rows(table), 25) |
There was a problem hiding this comment.
We can actually pass max_results to list_rows now.
Use max_results in list_rows.
tswast
left a comment
There was a problem hiding this comment.
Ah, I reviewed a second too soon. I see you've addressed the job_id and result changes. Thanks!
…of outdated 'publicdata'
…ease) [(googleapis#1178)](GoogleCloudPlatform/python-docs-samples#1178) * updates client.extract_table() sample * updates client.load_table_from_file() sample * updates client.load_table_from_uri() sample * updates parameterized query samples * updates query samples * updates dataset quickstart * fixes typo in sample * updates simple app sample * updates snippets * updates stream data sample * updates user credentials sample * removes job_id generation * Update BQ lib to 0.28.0. Use max_results in list_rows. * updates public dataset queries to use 'bigquery-public-data' instead of outdated 'publicdata' * updates readme and help sections
…ease) [(googleapis#1178)](GoogleCloudPlatform/python-docs-samples#1178) * updates client.extract_table() sample * updates client.load_table_from_file() sample * updates client.load_table_from_uri() sample * updates parameterized query samples * updates query samples * updates dataset quickstart * fixes typo in sample * updates simple app sample * updates snippets * updates stream data sample * updates user credentials sample * removes job_id generation * Update BQ lib to 0.28.0. Use max_results in list_rows. * updates public dataset queries to use 'bigquery-public-data' instead of outdated 'publicdata' * updates readme and help sections
…ease) [(#1178)](GoogleCloudPlatform/python-docs-samples#1178) * updates client.extract_table() sample * updates client.load_table_from_file() sample * updates client.load_table_from_uri() sample * updates parameterized query samples * updates query samples * updates dataset quickstart * fixes typo in sample * updates simple app sample * updates snippets * updates stream data sample * updates user credentials sample * removes job_id generation * Update BQ lib to 0.28.0. Use max_results in list_rows. * updates public dataset queries to use 'bigquery-public-data' instead of outdated 'publicdata' * updates readme and help sections
No description provided.