GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — docs(samples): add more clustering code snippets by ryanyuan · Pull Request #330 · googleapis/python-bigquery

This repository was archived by the owner on Mar 6, 2026. It is now read-only.

Conversation

@ryanyuan

@ryanyuan ryanyuan commented Oct 18, 2020

Copy link
Copy Markdown
Contributor

Add sample code for creating a clustered table from a query result.
File: samples/client_query_destination_table_clustered.py
Section: https://cloud.google.com/bigquery/docs/creating-clustered-tables#creating_a_clustered_table_from_a_query_result

Add sample code for creating a clustered table when you load data.
File: samples/load_table_clustered.py
Section: https://cloud.google.com/bigquery/docs/creating-clustered-tables#creating_a_clustered_table_when_you_load_data

Fixes #329 🦕

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@ryanyuan
ryanyuan requested a review from a team October 18, 2020 05:32
@ryanyuan
ryanyuan requested a review from a team as a code owner October 18, 2020 05:32
@ryanyuan
ryanyuan requested a review from engelke October 18, 2020 05:32
@google-cla google-cla Bot added the cla: yes This human has signed the Contributor License Agreement. label Oct 18, 2020
@ryanyuan
docs(samples): add more clustering code snippets
2ca69be
@ryanyuan
ryanyuan force-pushed the add-sample-code-clustering branch from e15442f to 2ca69be Compare October 19, 2020 22:14
@product-auto-label product-auto-label Bot added api: bigquery Issues related to the googleapis/python-bigquery API. samples Issues that are directly related to samples. labels Oct 22, 2020
tswast
tswast suggested changes Oct 29, 2020
View reviewed changes

@tswast tswast left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Thanks for the contribution! A couple of nits

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread samples/client_query_destination_table_clustered.py Outdated

def client_query_destination_table_clustered(table_id):

# [START bigquery_query_destination_table_clustered]

@tswast tswast Oct 29, 2020

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

We need to standardize with what the other languages are using.

Suggested change
# [START bigquery_query_destination_table_clustered]
# [START bigquery_query_clustered_table]

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread samples/client_query_destination_table_clustered.py Outdated
table = client.get_table(table_id) # Make an API request.
if table.clustering_fields == cluster_fields:
print("The destination table is written using the cluster_fields configuration.")
# [END bigquery_query_destination_table_clustered]

@tswast tswast Oct 29, 2020

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Suggested change
# [END bigquery_query_destination_table_clustered]
# [END bigquery_query_clustered_table]

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread samples/load_table_clustered.py Outdated
source_format=bigquery.SourceFormat.CSV,
)

with open(file_path, "rb") as source_file:

@tswast tswast Oct 29, 2020

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Nit: The Go sample loads from GCS "gs://cloud-samples-data/bigquery/sample-transactions/transactions.csv"

It'd be nice if we had some consistency across languages. Also, it's a little bit simpler to run the sample without the need for local files.

Go sample:

https://github.com/GoogleCloudPlatform/golang-samples/blob/7c9a079be0894b2c04c825c07d55176e65087c88/bigquery/snippets/loadingdata/bigquery_load_table_clustered.go#L17-L70

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
tswast added 2 commits November 4, 2020 10:34
@tswast
Merge remote-tracking branch 'upstream/master' into add-sample-code-c…
5ac35eb
…lustering
@tswast
docs: use clustered source file from GCS
307fb42
@snippet-bot

snippet-bot Bot commented Nov 4, 2020 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

Here is the summary of changes.

You added 4 region tags.
  • bigquery_query_clustered_table in docs/usage/tables.rst
  • bigquery_load_table_clustered in docs/usage/tables.rst
  • bigquery_query_clustered_table in samples/client_query_destination_table_clustered.py
  • bigquery_load_table_clustered in samples/load_table_clustered.py

This comment is generated by snippet-bot.
If you find problems with this result, please file an issue at:
https://github.com/googleapis/repo-automation-bots/issues.
To update this comment, add snippet-bot:force-run label.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

tswast
tswast approved these changes Nov 4, 2020
View reviewed changes
@tswast tswast added the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Nov 4, 2020
@yoshi-kokoro yoshi-kokoro removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Nov 4, 2020
@tswast
blacken
39d0c28
@tswast tswast added the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Nov 4, 2020
@yoshi-kokoro yoshi-kokoro removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Nov 4, 2020
@tswast
Merge branch 'master' into add-sample-code-clustering
ce9c62c
@tswast tswast added the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Nov 4, 2020
@yoshi-kokoro yoshi-kokoro removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Nov 4, 2020
@ryanyuan

ryanyuan commented Nov 4, 2020

Copy link
Copy Markdown
Contributor Author

@tswast thanks for the review and changes.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@ryanyuan
docs(samples): add more clustering code snippets
0293145
@tswast tswast added the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Nov 4, 2020
@yoshi-kokoro yoshi-kokoro removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Nov 4, 2020
engelke
engelke approved these changes Nov 16, 2020
View reviewed changes

@engelke engelke left a comment

Copy link
Copy Markdown

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

LGTM.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@tswast
Merge branch 'master' into add-sample-code-clustering
9cdad19
@tswast tswast added automerge Merge the pull request once unit tests and other checks pass. kokoro:force-run Add this label to force Kokoro to re-run the tests. labels Nov 17, 2020
@yoshi-kokoro yoshi-kokoro removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Nov 17, 2020
@gcf-merge-on-green
gcf-merge-on-green Bot merged commit 809e4a2 into googleapis:master Nov 17, 2020
@gcf-merge-on-green gcf-merge-on-green Bot removed the automerge Merge the pull request once unit tests and other checks pass. label Nov 17, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Reviewers

2 more reviewers
@engelke engelke engelke approved these changes
@tswast tswast tswast approved these changes
Reviewers whose approvals may not affect merge requirements

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

api: bigquery Issues related to the googleapis/python-bigquery API. cla: yes This human has signed the Contributor License Agreement. samples Issues that are directly related to samples.

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Add more code snippets for creating clustered table.

Uh oh!

There was an error while loading. Please reload this page.

4 participants

@ryanyuan @engelke @tswast @yoshi-kokoro
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.