import logging from apache_beam.internal.gcp import auth from apitools.base.py.exceptions import HttpError from apache_beam.io.gcp.internal.clients import bigquery def delete(project_id, dataset_id, table_id): client = bigquery.BigqueryV2( credentials=auth.get_service_credentials()) request = bigquery.BigqueryTablesDeleteRequest(projectId=project_id, datasetId=dataset_id, tableId=table_id) try: client.tables.Delete(request) except HttpError as exn: if exn.status_code == 404: logging.warning('Table %s:%s.%s does not exist', project_id, dataset_id, table_id) return else: raise