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---5
6# GCP Live BigQuery Dataset Deletion Guard
7
8## Purpose
9
10Act 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.
11
12## When to Use
13
14Use this skill when:
15
16- A BigQuery dataset is being deleted or a request to delete one is received
17- A BigQuery table is being truncated (all rows deleted, schema preserved)
18- An authorized view configuration is being changed or removed
19- A scheduled query referencing the dataset needs to be decommissioned first
20- A Data Transfer Service job is being removed alongside its target dataset
21- An operator needs to enumerate all resources and dependencies before a BigQuery decommissioning
22
23## When NOT to Use
24
25Do not use this skill when:
26
27- The task is creating a new dataset or table with no existing data at risk
28- The task is a read-only schema inspection or data quality audit with no deletion intent
29- The task involves Cloud Storage, Cloud SQL, or other non-BigQuery data stores
30- The task is modifying query logic or views without deleting any underlying data
31
32## Pre-Flight Checklist
33
34Before executing any BigQuery deletion or truncation, verify all of the following:
35
361. **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.
43
44## Required Confirmation
45
46The operator must explicitly state all of the following before any deletion is executed:
47
48- "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."
53
54## Execution Steps
55
561. 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).
65
66## Rollback Procedure
67
68- **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.
72
73## Post-Change Verification
74
751. 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.
79
80## Response Shape
81
821. Project and dataset identity confirmation
832. Dataset inventory (tables, views, routines, bytes stored)
843. Downstream dependency audit (scheduled queries, DTS jobs, authorized views)
854. Export/backup confirmation before deletion
865. Approval status
876. Executed deletion or truncation action
887. Post-change pipeline impact verification