1
votes

The BigQuery's Scheduled Query is an interesting one and for GCP to enable the creation of one programmatically via its CLI tool offers some flexibilities and conveniences. After creating a few SQs I realised, from time to time, updates needs to be done on one or several of the SQ.

The challenge here is finding a way to update/ or delete/ or enable/disable an existing scheduled query via the CLI. GCP's documentation clearly explained how one can create using either the bq query or bq mk command. There is absolutely nowhere to suggest we can delete or update/modify an existing scheduled query either via CLI or Python.

I was thinking of bq rm but there isn't a flag to specifically deletes a scheduled query. I may be risking dropping an entire dataset or table.

Perhaps it is a limitation at the moment. However, if anyone has found a way to do so, please share your solution or your way around.

1

1 Answers

0
votes

sorry for the confusion.

Scheduled query does support update/delete in CLI. Scheduled query is managed as a transfer config in CLI, please see update transfer config and delete transfer config.

For example, to update/delete a scheduled query with name projects/p/locations/us/transferConfigs/scheduled_query:

# Update the query parameter in a scheduled query.
bq update --transfer_config --params='{"query":"SELECT 1"}' projects/p/locations/us/transferConfigs/scheduled_query

# Delete a scheduled query.
bq rm --transfer_config projects/p/locations/us/transferConfigs/scheduled_query

Hope this helps!