I’ve recently looked into using the INFORMATION_SCHEMA.TABLE_SCHEMA metadata to analyse storage costs ahead of the incoming price rises for BigQuery.
Running the following query:
select * from region-europe-west2.INFORMATION_SCHEMA.TABLE_STORAGE
Returns a lot of rows with dataset names (table_schema) that are not visible in the UI or via a bq show command and do not have the deleted field set to true against them.
These datasets all appear to have active storage against them, but were likely deleted a long time ago.
I am a project owner and just to be sure I have the BigQuery Admin role set against my username.
Why would the TABLE_STORAGE view return these tables? How do I access (and delete) them?
Here are some possible reasons for what you are experiencing.
The tables may not have been entirely removed by BigQuery. BigQuery occasionally delays the actual deletion of tables. The tables may still be kept for a few times even after being erased using the UI or using the bq show command.
To access and delete these tables, you can use the bq rm command in the Cloud SDK. This command can be used to delete tables that are not visible in the UI or via a bq show command. You will need to provide the full table path, including the project ID, dataset name (table_schema), and table name.
When a table is deleted, there could be some time before the deleted field is set to true. BigQuery sets this column to signal that a table has been deleted and can now be removed without risk. There might be a lag in setting this column, which would result in the deleted tables still showing up in the metadata.
BigQuery’s INFORMATION_SCHEMA.TABLE_STORAGE view offers information on how much storage your project’s tables are using. It’s possible that the view is returning metadata about removed tables that are still being used for storage.
The bq rm command in the Cloud SDK can be used to access and remove these tables; it can also be used to delete tables that are not available in the UI or via a bq show command. The project ID, dataset name (table_schema), and table name must all be included in the whole table path.