Skip to content

Commit

Permalink
fix: ignore projects when bigquery api is not enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
gabriel-milan committed Oct 20, 2023
1 parent b95b356 commit f26ce34
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion pipelines/rj_escritorio/data_catalog/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"""
from typing import List

from google.api_core.exceptions import NotFound
from google.cloud import bigquery
from googleapiclient import discovery
import gspread
Expand Down Expand Up @@ -88,7 +89,13 @@ def list_tables( # pylint: disable=too-many-arguments
client = get_bigquery_client(mode=mode)
log(f"Listing tables in project {project_id}.")
tables = []
for dataset in client.list_datasets(project=project_id):
try:
datasets = client.list_datasets(project=project_id)
except NotFound:
# This will happen if BigQuery API is not enabled for this project. Just return an empty
# list
return tables
for dataset in datasets:
dataset_id: str = dataset.dataset_id
if exclude_staging and dataset_id.endswith("_staging"):
log(f"Excluding staging dataset {dataset_id}.")
Expand Down

0 comments on commit f26ce34

Please sign in to comment.