We prefer coding Snowflake stored procedures and javascript UDF's using the $$ notation. It is easier as we do not have to worry about escaping every single quote in our code. However, when we retrieve the DDL using GET_DDL, Snowflake removes the $$ and places the body of the SP in single quotes and also escapes every single quote.
Is there a way to get the SP DDL from Snowflake in the $$ format?
Example, below is the SP we create. Notice the $$ sign and that we do not hae
CREATE OR REPLACE PROCEDURE "SP_TEST"()
RETURNS VARCHAR(16777216)
LANGUAGE JAVASCRIPT
EXECUTE AS CALLER
AS $$
var result = snowflake.execute({sqlText: "select 'Hello World!' as test;"})
result.next();
return String(result.getColumnValue(1));
$$;
Then, when we retrieve the DDL from Snowflake using SELECT GET_DDL('PROCEDURE','SP_TEST()'), we get the following. Notice the $$ has been replaced by single quotes and that all other single quotes are now escaped.
CREATE OR REPLACE PROCEDURE "SP_TEST"()
RETURNS VARCHAR(16777216)
LANGUAGE JAVASCRIPT
EXECUTE AS CALLER
AS '
var result = snowflake.execute({sqlText: "select ''Hello World!'' as test;"})
result.next();
return String(result.getColumnValue(1));
';
Thanks