I'm using BigQuery Python Client version google-cloud-bigquery==2.15.0 and sometimes when I update (PATCH) a table via:
client.update_table(table, ["labels", "description"])
I got the following error
PreconditionFailed('PATCH
https://bigquery.googleapis.com/bigquery/v2/projects/my-proj/datasets/my-ds/tables/my-table?prettyPrint=false
: Precondition check failed.')
There is a closed issue https://github.com/googleapis/google-cloud-python/issues/5588 on Github related to this. Is has been resolved in a PR in 2018. But I'm still getting the error.
Any idea? Should I just upgrade to the latest version?
I've encounter a similar situation, out of the blue I started getting PRECONDITION_FAILED: 412 errors on updating schemas via bq_client.update_table(table, ["schema"]) with just one new column while before everything worked fine. I found out that the reason for this error was the fact that I were updating the table via DDL:
table = self.bq_client.get_table(table_ref)
...
sql = f"ALTER TABLE `{table_name}` DROP COLUMN {field.name}"
self.execute_query(sql)
...
table = self.bq_client.update_table(table, ["schema"])
to work around the error I added re-fetching the table's schema:
table = self.bq_client.get_table(table_ref)
table = self.bq_client.update_table(table, ["schema"])
after that everything started working fine
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With