I have deleted a view in bigquery. I came to know there is an option to restore deleted tables based on table snapshot decorators. Is there any way to retrieve deleted bigquery views?
Asked
Active
Viewed 7,014 times
1 Answers
32
There is a way to get it back. You need to search for insertion logs rolled at a time of creating your view. This logs can be seen from stackdriver logging. Here are the steps :
Go to GCP console
Click on stackdriver logging
- Click on arrow present in search text box and select "Convert to advance filter"
- Now remove everything and paste below query in it. Don't forget to put your view name in a query.
resource.type="bigquery_resource"
protoPayload.methodName="tableservice.insert"
protoPayload.serviceData.tableInsertRequest.resource.tableName.tableId="Your_view_name"
- You will get record of your view creation, Now click on Expand all and go to view section. There you can find a query used at a time of view creation.
- Just paste that query in bigquery and click on save view.
Alternatively, if you want to search for updates to the view to recover a specific version you can use the following filter:
resource.type="bigquery_resource"
protoPayload.serviceData.tableUpdateRequest.resource.tableName.datasetId="<dataset_id>"
protoPayload.resourceName="projects/<project_id>/datasets/<dataset_id>/tables/<table_or_view_id>"
I hope this helps you get back your BQ view.

rahlf23
- 8,869
- 4
- 24
- 54

Indrajeet Patil
- 635
- 1
- 7
- 15
-
2I think you just saved my life – minocha Feb 13 '19 at 23:23
-
Always at your service Sir..! – Indrajeet Patil Apr 27 '19 at 09:24
-
I found it from over a year back – minocha Jun 30 '20 at 11:28
-
Incredible. I found my view from 7 months ago. Lifesaver. – Steve Simitzis Jan 22 '21 at 05:05
-
you just saved me several hours of work, thank you! – Shahin Ghannadian May 25 '21 at 00:56