in components/doc-deletion/src/doc_deletion_main.py [0:0]
def drop_data_table(bq_client: bigquery.Client, data_table: str):
logger.info(
f"Dropping table {data_table} due to batch mode. Verifying table is empty."
)
res = bq_client.query(f"SELECT COUNT(*) AS row_count FROM {data_table}")
if res.errors:
raise Exception(res.errors[0]["message"])
row_count = [row["row_count"] for row in res.result()][0]
if row_count > 0:
raise Exception(
f"Something went wrong. Table is not empty. Still contains {row_count} rows"
)
logger.info(f"Table {data_table} is empty. Proceeding to drop it.")
res = bq_client.query(f"DROP TABLE {data_table}")
if res.errors:
raise Exception(res.errors[0]["message"])