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

feat(bigquery): Add Clone() method to bigquery.Schema #10584

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

IvanIsCoding
Copy link

This is mostly a convenience method. It comes in handy when creating Views from BigQuery, because we want to have a subset of the fields for the View but still want to keep the original FieldSchema entries of the cloned object intact.

There is nothing here that could not be replicated in clients because all the fields of the struct are exported, but it would be good if this was supported upstream.

@IvanIsCoding IvanIsCoding requested review from a team as code owners July 24, 2024 19:17
@product-auto-label product-auto-label bot added the api: bigquery Issues related to the BigQuery API. label Jul 24, 2024
@hongalex hongalex requested review from shollyman and removed request for hongalex August 26, 2024 19:57
@shollyman
Copy link
Contributor

The PR itself looks straightforward, but I wanted to understand how you're leveraging this. You mention views, but they're not typically defined via the output schema. Can you elaborate a bit more? Thanks!

@IvanIsCoding
Copy link
Author

The PR itself looks straightforward, but I wanted to understand how you're leveraging this. You mention views, but they're not typically defined via the output schema. Can you elaborate a bit more? Thanks!

Sure, that is a good question. I mentioned BigQuery Views because my team uses views, but it could also apply to folks copying tables. We want to keep track of what is the schema for queries like:

SELECT A, B, C
FROM TABLE

For us, it is easier to clone the schema from TABLE and delete what is not in the SELECT statement, because our queries generally have lots of columns. The extreme is the case with EXCEPT clauses:

SELECT * EXCEPT D, E
FROM TABLE

where the clone method with deleting is the best way to keep track of the columns shown for the View.

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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants