Google-cloud-python: BigQuery: sample(s) for replacing data in a partition with WRITE_TRUNCATE

Created on 30 Jan 2018  路  3Comments  路  Source: googleapis/google-cloud-python

Feature request

Ability to use replace flag for a date partitioned table in order to effectively delete that date partition and add new data. Simply a feature which replicates functionality provided by bq CLI tool shown here: https://cloud.google.com/bigquery/docs/creating-partitioned-tables#restating_data_in_a_partition

bigquery docs

Most helpful comment

I believe the replace flag in the CLI uses the "write disposition" parameter. An example of replacing a table with a load job is available at:

https://github.com/GoogleCloudPlatform/google-cloud-python/blob/8498a677e20da7d43db1d1011662ebdc78bd0184/docs/bigquery/snippets.py#L611-L630

To replace a partition use the partition in the table ID. e.g.

table_ref = client.dataset('my_dataset').table('existing_table$20180131')

The action item I see here is:

  • Show writing to a specific partition of a destination table.

All 3 comments

I believe the replace flag in the CLI uses the "write disposition" parameter. An example of replacing a table with a load job is available at:

https://github.com/GoogleCloudPlatform/google-cloud-python/blob/8498a677e20da7d43db1d1011662ebdc78bd0184/docs/bigquery/snippets.py#L611-L630

To replace a partition use the partition in the table ID. e.g.

table_ref = client.dataset('my_dataset').table('existing_table$20180131')

The action item I see here is:

  • Show writing to a specific partition of a destination table.

Ah! That makes sense 馃憤 Thanks for providing the example.

I'm closing preemptively here. Please feel free to reopen if a partition-specific snippet is needed, versus the general one @tswast linked.

Was this page helpful?
0 / 5 - 0 ratings