In snowflake, we can set and read the session variables using SET and SELECTs:
SET FOO_BAR='foobar'
SELECT $FOO_BAR
But the variable I am dealing with has special character "." and the above statements don't work. I can get the SET to work by double quoting the variable name
SET "FOO.BAR" = 'foobar'
But SELECT $"FOO.BAR" does not work (or other variations of it)
I can use SHOW VARIABLES like 'FOO.BAR' and that works, but I was interested in getting select working so I can use it queries. Any idea how can I use select to read such variables?
CodePudding user response:
You can use GETVARIABLE() function to access these kinds of variables:
SET "FOO.BAR" ='foo.bar';
SELECT GETVARIABLE('FOO.BAR');
https://docs.snowflake.com/en/sql-reference/session-variables.html#session-variable-functions
