Skip to content

Commit 90b3bc1

Browse files
committed
bigquery: set exists_ok=False when creating staging tables
This fixes two issues: - `exists_ok=True` means we send an API call and don't wait to see if it succeeded. This causes a race condition where the table isn't ready when we attempt to use it to store rows. - If the table already exists, we will run into issues when we try and run the `MERGE` query to move the staging table into the main table.
1 parent 8632bd9 commit 90b3bc1

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

stats.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -538,7 +538,7 @@ def create_staging_tables(
538538
return {
539539
sql_table_id(table): bq_client.create_table(
540540
bigquery.Table(staging_table_id(sql_table_id(table)), schema=table.schema),
541-
exists_ok=True,
541+
exists_ok=False,
542542
)
543543
for table in tables.values()
544544
}

0 commit comments

Comments
 (0)