GCP Live BigQuery Dataset Deletion Guard
Purpose
Act as the guarded live GCP operator for gcp-live-bigquery-dataset-deletion-guard work. Gate every BigQuery dataset deletion, table truncation, and authorized view change with a complete downstream dependency audit and export confirmation. Dataset deletion in BigQuery is immediate and permanent — there is no recycle bin, and all downstream pipelines break the moment the dataset is gone.
When to Use
Use this skill when:
- A BigQuery dataset is being deleted or a request to delete one is received
- A BigQuery table is being truncated (all rows deleted, schema preserved)
- An authorized view configuration is being changed or removed
- A scheduled query referencing the dataset needs to be decommissioned first
- A Data Transfer Service job is being removed alongside its target dataset
- An operator needs to enumerate all resources and dependencies before a BigQuery decommissioning
When NOT to Use
Do not use this skill when:
- The task is creating a new dataset or table with no existing data at risk
- The task is a read-only schema inspection or data quality audit with no deletion intent
- The task involves Cloud Storage, Cloud SQL, or other non-BigQuery data stores
- The task is modifying query logic or views without deleting any underlying data
Pre-Flight Checklist
Before executing any BigQuery deletion or truncation, verify all of the following:
- Dataset identity confirmed — run
bq show --format=prettyjson <PROJECT>:<DATASET> and confirm the dataset name, project, and location match the intended target.
- Dataset inventory captured — run
bq ls <PROJECT>:<DATASET> to enumerate all tables, views, and external tables. Document the table count and total bytes stored.
- Scheduled queries audited — run
bq ls --transfer_config --transfer_location=<LOCATION> --project_id=<PROJECT> to list all scheduled queries and Data Transfer jobs that reference this dataset.
- Authorized views audited — check all authorized views that grant access to this dataset; identify any cross-project views that will break.
- Downstream pipeline dependencies confirmed — check Dataflow jobs, Looker/Looker Studio connections, and any application code that references the dataset for active dependencies.
- Export/backup confirmed — for production datasets, confirm that a full export to Cloud Storage (Avro, Parquet, or JSON) has been completed and verified before deletion is authorized.
- Data retention policy reviewed — confirm there are no legal hold, compliance retention, or regulatory requirements that prevent deletion.
Required Confirmation
The operator must explicitly state all of the following before any deletion is executed:
- "I confirm the target is dataset
<DATASET_ID> in project <PROJECT_ID>, location <LOCATION>."
- "I have reviewed the dataset inventory:
<N> tables, <N> views, approximately <X> bytes."
- "I have audited downstream dependencies and confirmed all scheduled queries and DTS jobs have been decommissioned or will tolerate this deletion."
- "I confirm that an export/backup has been completed (or that no backup is required with documented justification)."
- "I approve this deletion."
Execution Steps
- Capture full dataset inventory and downstream dependency audit.
- Confirm active principal has
roles/bigquery.dataOwner for the target dataset.
- Present the dataset inventory, dependency findings, and export status to the operator for explicit approval.
- Execute the mutation:
- Delete dataset (with all contents):
bq rm -r -f <PROJECT>:<DATASET>
- Delete a single table:
bq rm -f <PROJECT>:<DATASET>.<TABLE>
- Truncate a table (delete all rows):
bq query --nouse_legacy_sql 'TRUNCATE TABLE \..`'`
- Update authorized views:
bq update --source <JSON_FILE> <PROJECT>:<DATASET>
- Confirm the deletion is reflected with
bq ls <PROJECT>: (dataset should not appear).
Rollback Procedure
- Dataset deletion (NOT reversible): BigQuery dataset deletion is immediate and permanent. There is no recycle bin. If deletion was accidental, the only recovery path is restoring from a Cloud Storage export.
- Table deletion (partially recoverable): If the table had a default expiration set, it may appear in the BigQuery
__TABLES__ metadata with an expiration timestamp — but this does not allow recovery after deletion.
- Table truncation (NOT reversible without backup): Truncation removes all rows. Recovery requires restoring from an export or a snapshot.
- For accidental deletion, immediately open a GCP Support case and provide the dataset resource path and deletion timestamp from Cloud Audit Logs.
Post-Change Verification
- Run
bq ls <PROJECT>: — confirm the deleted dataset no longer appears.
- Check Cloud Audit Logs for the deletion event:
gcloud logging read 'protoPayload.methodName="google.cloud.bigquery.v2.DatasetService.DeleteDataset"' --limit=5 --project=<PROJECT>.
- Monitor scheduled query runs in the 24 hours following deletion — confirm no pipeline failures are attributed to the deleted dataset.
- Check Dataflow job logs and Looker connection health for any errors referencing the deleted dataset.
Response Shape
- Project and dataset identity confirmation
- Dataset inventory (tables, views, routines, bytes stored)
- Downstream dependency audit (scheduled queries, DTS jobs, authorized views)
- Export/backup confirmation before deletion
- Approval status
- Executed deletion or truncation action
- Post-change pipeline impact verification
1---2name: gcp-live-bigquery-dataset-deletion-guard3description: Gate BigQuery dataset deletion, table truncation, and authorized view changes against a full downstream dependency audit and export confirmation. Dataset deletion is immediate and permanent with no recycle bin — this guard ensures no dataset is deleted without enumerating all tables, scheduled queries, Data Transfer jobs, Looker connections, and Dataflow pipelines that depend on it.4---56# GCP Live BigQuery Dataset Deletion Guard78## Purpose910Act as the guarded live GCP operator for gcp-live-bigquery-dataset-deletion-guard work. Gate every BigQuery dataset deletion, table truncation, and authorized view change with a complete downstream dependency audit and export confirmation. Dataset deletion in BigQuery is immediate and permanent — there is no recycle bin, and all downstream pipelines break the moment the dataset is gone.1112## When to Use1314Use this skill when:1516- A BigQuery dataset is being deleted or a request to delete one is received17- A BigQuery table is being truncated (all rows deleted, schema preserved)18- An authorized view configuration is being changed or removed19- A scheduled query referencing the dataset needs to be decommissioned first20- A Data Transfer Service job is being removed alongside its target dataset21- An operator needs to enumerate all resources and dependencies before a BigQuery decommissioning2223## When NOT to Use2425Do not use this skill when:2627- The task is creating a new dataset or table with no existing data at risk28- The task is a read-only schema inspection or data quality audit with no deletion intent29- The task involves Cloud Storage, Cloud SQL, or other non-BigQuery data stores30- The task is modifying query logic or views without deleting any underlying data3132## Pre-Flight Checklist3334Before executing any BigQuery deletion or truncation, verify all of the following:35361. **Dataset identity confirmed** — run `bq show --format=prettyjson <PROJECT>:<DATASET>` and confirm the dataset name, project, and location match the intended target.372. **Dataset inventory captured** — run `bq ls <PROJECT>:<DATASET>` to enumerate all tables, views, and external tables. Document the table count and total bytes stored.383. **Scheduled queries audited** — run `bq ls --transfer_config --transfer_location=<LOCATION> --project_id=<PROJECT>` to list all scheduled queries and Data Transfer jobs that reference this dataset.394. **Authorized views audited** — check all authorized views that grant access to this dataset; identify any cross-project views that will break.405. **Downstream pipeline dependencies confirmed** — check Dataflow jobs, Looker/Looker Studio connections, and any application code that references the dataset for active dependencies.416. **Export/backup confirmed** — for production datasets, confirm that a full export to Cloud Storage (Avro, Parquet, or JSON) has been completed and verified before deletion is authorized.427. **Data retention policy reviewed** — confirm there are no legal hold, compliance retention, or regulatory requirements that prevent deletion.4344## Required Confirmation4546The operator must explicitly state all of the following before any deletion is executed:4748- "I confirm the target is dataset `<DATASET_ID>` in project `<PROJECT_ID>`, location `<LOCATION>`."49- "I have reviewed the dataset inventory: `<N>` tables, `<N>` views, approximately `<X>` bytes."50- "I have audited downstream dependencies and confirmed all scheduled queries and DTS jobs have been decommissioned or will tolerate this deletion."51- "I confirm that an export/backup has been completed (or that no backup is required with documented justification)."52- "I approve this deletion."5354## Execution Steps55561. Capture full dataset inventory and downstream dependency audit.572. Confirm active principal has `roles/bigquery.dataOwner` for the target dataset.583. Present the dataset inventory, dependency findings, and export status to the operator for explicit approval.594. Execute the mutation:60 - Delete dataset (with all contents): `bq rm -r -f <PROJECT>:<DATASET>`61 - Delete a single table: `bq rm -f <PROJECT>:<DATASET>.<TABLE>`62 - Truncate a table (delete all rows): `bq query --nouse_legacy_sql 'TRUNCATE TABLE \`<PROJECT>.<DATASET>.<TABLE>\`'`63 - Update authorized views: `bq update --source <JSON_FILE> <PROJECT>:<DATASET>`645. Confirm the deletion is reflected with `bq ls <PROJECT>:` (dataset should not appear).6566## Rollback Procedure6768- **Dataset deletion** (NOT reversible): BigQuery dataset deletion is immediate and permanent. There is no recycle bin. If deletion was accidental, the only recovery path is restoring from a Cloud Storage export.69- **Table deletion** (partially recoverable): If the table had a default expiration set, it may appear in the BigQuery `__TABLES__` metadata with an expiration timestamp — but this does not allow recovery after deletion.70- **Table truncation** (NOT reversible without backup): Truncation removes all rows. Recovery requires restoring from an export or a snapshot.71- For accidental deletion, immediately open a GCP Support case and provide the dataset resource path and deletion timestamp from Cloud Audit Logs.7273## Post-Change Verification74751. Run `bq ls <PROJECT>:` — confirm the deleted dataset no longer appears.762. Check Cloud Audit Logs for the deletion event: `gcloud logging read 'protoPayload.methodName="google.cloud.bigquery.v2.DatasetService.DeleteDataset"' --limit=5 --project=<PROJECT>`.773. Monitor scheduled query runs in the 24 hours following deletion — confirm no pipeline failures are attributed to the deleted dataset.784. Check Dataflow job logs and Looker connection health for any errors referencing the deleted dataset.7980## Response Shape81821. Project and dataset identity confirmation832. Dataset inventory (tables, views, routines, bytes stored)843. Downstream dependency audit (scheduled queries, DTS jobs, authorized views)854. Export/backup confirmation before deletion865. Approval status876. Executed deletion or truncation action887. Post-change pipeline impact verification