6
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

ZOZOテクノロジーズ #1Advent Calendar 2020

Day 14

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;
6
2
0

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
6
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?