Last active
April 23, 2022 07:30
-
-
Save CAFxX/31023c99556443d058577346c7ce691e to your computer and use it in GitHub Desktop.
Ensure at most a single BigQuery scheduled query is running at one time
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DECLARE check_running_jobs DEFAULT ( | |
SELECT IF(COUNT(*) > 1, ERROR('query already running'), NULL) | |
FROM `region-name`.INFORMATION_SCHEMA.JOBS_BY_PROJECT | |
WHERE state <> 'DONE' | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Note: you can't use this if you use a destination table. In this case you should remove the destination table from the scheduled query definition and rewrite your query as