Created
February 23, 2024 12:53
-
-
Save salvadorgascon/ba15a2158f9de7bd07d16beed83a0f5e to your computer and use it in GitHub Desktop.
Check if exists a table object in Google Cloud BigQuery
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
BIGQUERY_PROJECT_NAME = "project-XXXXXX" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from google.cloud import bigquery | |
from google.cloud.exceptions import NotFound | |
from shared.loaders.bigquery_constants import BIGQUERY_PROJECT_NAME | |
def BigQueryTableExists(bigquery_client, bigquery_dataset_name, bigquery_table_name): | |
try: | |
bigquery_client.get_table(f'{BIGQUERY_PROJECT_NAME}.{bigquery_dataset_name}.{bigquery_table_name}') | |
return True | |
except NotFound: | |
return False |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment