I am working in Snowflake and have a column pets that I'm trying to put into a url friendly format so they can be concatenated to links within Metabase. Example:
'Tom & Jerry' -> 'Tom%20%26%20Jerry'
Is there a function in Snowflake that does this?
I don't think there is one. But Javascript has sush a thing, so we can wrap that into a function:
create function urlencodestring(str string)
returns string
language javascript
strict
as
'
return encodeURIComponent(STR);
';
then go crazy:
select urlencodestring('Tom & Jerry');
| URLENCODESTRING('TOM & JERRY') |
|---|
| Tom%20%26%20Jerry |