Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

Big Query - Retrieve a deleted scheduled query

I accidentally deleted a scheduled query In Big Query.

I can't anyway a way to retrieve it, is it possible ?

 

 

0 1 1,780
1 REPLY 1

It’s not possible to directly restore a deleted scheduled query in BigQuery, however you can still retrieve the SQL of a specific run of that scheduled query. Here's how:

  1. Navigate to the Scheduled queries section in the BigQuery console.
  2. If the deleted scheduled query's recent run is visible, click on its name.
  3. Go to the History tab to view the list of runs.
  4. Identify the run you're interested in and note down its job ID.
  5. Open the Cloud Shell terminal and use the following command:

bq --format=prettyjson show -j <job_id>

Replace <job_id> with the job ID you noted earlier. This command will display the details of that specific job run, including the SQL query.

For example, the output might look like:

{

"jobReference": {
"jobId": "scheduled_query_75adfjida2-9654-5884-4547-001affadf56",
"projectId": "my-project-id",
"location": "US"
},
"configuration": {
"query": "SELECT * FROM my_table"
},
...
}

Once you have the SQL query, you can manually recreate the scheduled query. You'll need:

  • The name you used for the original scheduled query.
  • The dataset it was set to run on.
  • The SQL query itself.
  • The schedule (frequency) at which it was set to run.