Can we pass list or array as parameter to javascript procedure in snowflake?
I am working on procedure which would run weekly and delete a week old data from certain tables. Instead of creating task for individual table, I want to pass table names as list/array.
Please guide.
Thanks in advance!
Yes, you can pass an array into a Snowflake JavaScript stored procedure. Here's a sample:
create or replace procedure test(ARR array)
returns string
language javascript
as
$$
var i;
var out = "";
// Remember to capitalize variables input to the stored procedure definition
for(i = 0; i < ARR.length; i++){
out += ARR[i];
if (i < ARR.length - 1) out += ", ";
}
return out;
$$;
call test(array_construct('TABLE_1', 'TABLE_2', 'TABLE_3'));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With