You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Mar 6, 2026. It is now read-only.
fromgoogle.cloudimportbigqueryfromgoogle.api_core.exceptionsimportAlreadyExists, Conflict# Construct a BigQuery client object.client=bigquery.Client()
# TODO(developer): Set table_id to the ID of the table to create.table_id="your-project.your_dataset.your_table_name"table=bigquery.Table(table_id)
table=client.create_table(table) # Make an API request.try:
table=client.create_table(table) # Make an API request. Second time.exceptAlreadyExists:
print("Caught google.api_core.exceptions.AlreadyExists")
exceptConflict:
print("Caught google.api_core.exceptions.Conflict")
table=client.create_table(table) # Make an API request. Third time for Stack Trace
Stack trace
$ /usr/bin/python3 REDACTED/example.py
Caught google.api_core.exceptions.Conflict
Traceback (most recent call last):
File "REDACTED/example.py", line 19, in<module>
table = client.create_table(table) # Make an API request. Third time for Stack Trace
File "/home/REDACTED/.local/lib/python3.8/site-packages/google/cloud/bigquery/client.py", line 543, in create_table
api_response = self._call_api(
File "/home/REDACTED/.local/lib/python3.8/site-packages/google/cloud/bigquery/client.py", line 556, in _call_api
returncall()
File "/home/REDACTED/.local/lib/python3.8/site-packages/google/api_core/retry.py", line 281, in retry_wrapped_func
return retry_target(
File "/home/REDACTED/.local/lib/python3.8/site-packages/google/api_core/retry.py", line 184, in retry_target
returntarget()
File "/home/REDACTED/.local/lib/python3.8/site-packages/google/cloud/_http.py", line 423, in api_request
raise exceptions.from_http_response(response)
google.api_core.exceptions.Conflict: 409 POST https://bigquery.googleapis.com/bigquery/v2/projects/REDACTED/datasets/REDACTED/tables: Already Exists: Table REDACTED:REDACTED.your_table_name
Environment details
API: BigQuery
OS type and version:
Python version and virtual environment information:
google-cloud-bigquery version:
Steps to reproduce
client.create_table()google.api_core.exceptions.Conflictgoogle.api_core.exceptions.AlreadyExistsclient.delete_table()with a non-existent table and the result isgoogle.api_core.exceptions.NotFoundCode example
Slightly modified version of https://cloud.google.com/bigquery/docs/tables#python
Stack trace