LoginSignup
2

More than 3 years have passed since last update.

BigQuery Scriptingでsleep

Last updated at Posted at 2020-12-13

BigQuery Scriptingで処理を書いている途中で、少しだけ待ち時間を挟みたいことがたまにあります。
そんな時用のsleep処理をprocedureとして書いてみました。

CREATE OR REPLACE PROCEDURE `<プロジェクト名>.<データセット名>.sleep`(IN sec INT64)
BEGIN
  DECLARE now TIMESTAMP DEFAULT CURRENT_TIMESTAMP();
  DECLARE finish TIMESTAMP DEFAULT TIMESTAMP_ADD(CURRENT_TIMESTAMP(), INTERVAL sec SECOND);

  WHILE now < finish DO
    SET now = CURRENT_TIMESTAMP();
  END WHILE;
END;

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2