-
Notifications
You must be signed in to change notification settings - Fork 6.6k
BigQuery : add sample for writing query results to a destination table. #1101
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
Conversation
|
||
args = parser.parse_args() | ||
|
||
if args.use_standard_sql: | ||
query_standard_sql(args.query) | ||
elif args.destination_table: | ||
dataset, table = args.destination_table.split('.') |
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 could use a simple regular expression to validate that the destination table name is in the correct format, i.e. dataset_name.table_name
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.
However, this being a sample, it might be a better idea to keep unnecessary complexity down. So I'll leave that to you
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.
I'd rather keep the complexity low.
Please do whatever you think best for the validation comment, otherwise LGTM |
# Allow the results table to be overwritten. | ||
query_job.write_disposition = 'WRITE_TRUNCATE' | ||
|
||
query_job.begin() |
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.
doesn't .result() call .begin()?
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.
Oh, I didn't realize that. I can update the sample if so.
See: https://cloud.google.com/bigquery/docs/writing-results