bigfunctions icon indicating copy to clipboard operation
bigfunctions copied to clipboard

[new]: `sleep(time ms)`

Open Mmoncadaisla opened this issue 3 years ago • 4 comments

Check the idea has not already been suggested

Edit the title above with self-explanatory function name and argument names

  • [X] The function name and the argument names I entered in the title above seems self explanatory to me.

BigFunction Description as it would appear in the documentation

Returns NULL after input time (ms)

Examples of (arguments, expected output) as they would appear in the documentation

  • sleep(1000) --> Returns NULL after 1 seconds
  • sleep(60000) --> Returns NULL after 60 seconds

Mmoncadaisla avatar Dec 07 '22 16:12 Mmoncadaisla

Hi 👋,

Can you add some more background to this function? i.e.

  1. What's the significance of adding a delay in query execution?
  2. What use cases you're thinking of for using this sleep?

shivam221098 avatar Apr 01 '23 04:04 shivam221098

This function was added in décember 2023 :

bigfunctions.eu.sleep(10)

where sleep function get's seconds in param (not ms) i guess it covers this current need ?!

AntoineGiraud avatar Jul 26 '24 06:07 AntoineGiraud

@shivam221098, example of use case :

  • propagating descriptions on columns from an other query ... where you can only do 5 DDL per 10 seconds ! image

example :

DECLARE i INT64 DEFAULT 5;
FOR sql_alter_descr in (/* {select generating DDL alter table column set options descriptions commands } */)
DO
  execute immediate sql_alter_descr.sql;
  SET i = i + 1;
  IF (i>=5) THEN
    -- sleep of 10s every 5 DDL edits on a table
    CALL bigfunctions.eu.sleep(10);
    SET i = 0;
  END IF;
END FOR;

AntoineGiraud avatar Jul 26 '24 06:07 AntoineGiraud

@AntoineGiraud That's great. That made sense.

shivam221098 avatar Jul 26 '24 07:07 shivam221098