Snowflake – Getting invalid identifier error while passing variables between SQL Stored Procs

Advertisements I have a Snowflake SQL stored procedure from where I’m trying to call the SYSTEM$SEND_EMAIL function, but its erroring out as below: `create or replace procedure testsproc() RETURNS VARCHAR language sql as $$ BEGIN SELECT * FROM non_existent_table; EXCEPTION WHEN OTHER THEN LET LINE := SQLCODE || ‘: ‘ || SQLERRM; INSERT INTO myexception… Read More Snowflake – Getting invalid identifier error while passing variables between SQL Stored Procs

Generating UUID off Md5 Hash in Snowflake

Advertisements I have a table in Snowflake generated like: create or replace temporary table example (asset_id int, assignment_id int); insert into example (asset_id, assignment_id) values (5000, 1), (5000, 1), (5000, 1), (6000, 1), (6000, 2); select asset_id, assignment_id, uuid_string(uuid_string(), md5(concat(asset_id, assignment_id))) as uuid_assignment from example; I’d like to generate a uuid_string() for the combination of… Read More Generating UUID off Md5 Hash in Snowflake

how to get 1st column value using partition

Advertisements I have a table looks like this CREATE TABLE myTable ( userid text, webid text, "timestamp" timestamp ); INSERT INTO myTable ("userid", "webid", "timestamp") VALUES (‘A’, ’34’, ‘2023-01-31 17:34:49.000’), (‘A’, ’73’, ‘2023-01-31 17:34:50.000’), (‘A’, ’97’, ‘2023-01-31 17:34:58.000’), (‘A’, ’17’, ‘2023-01-31 17:35:02.000’), (‘A’, ’17’, ‘2023-01-31 17:35:07.000’), (‘A’, ’17’, ‘2023-01-31 17:35:18.000’), (‘A’, ’17’, ‘2023-01-31 17:35:30.000’), (‘A’,… Read More how to get 1st column value using partition

Snowflake SQL group-by behaving differently depending whether columns are referenced by position or alias

Advertisements I am trying to understand why the group by function is yielding different results in snowflake depending on how I reference the group-by fields. Here are two Queries that I believe should yield the same result, but do NOT: Query using explicit field alias references: select hash(‘SHA2_256’, CONCAT(‘field1′,’field2′,’field3′,’field4’)) as hash ,field1 ,field2 ,field3 ,field4… Read More Snowflake SQL group-by behaving differently depending whether columns are referenced by position or alias

How can you filter Snowflake EXPLAIN AS TABULAR syntax when its embedded in the TABLE function? Can you filter it with anything?

Advertisements I have a table named Posts I would like to count and profile in Snowflake using the current Snowsight UI. When I return the results via EXPLAIN using TABLULAR I am able to return the set with the combination of TABLE, RESULT_SCAN, and LAST_QUERY_ID functions, but any predicate or filter or column reference seems… Read More How can you filter Snowflake EXPLAIN AS TABULAR syntax when its embedded in the TABLE function? Can you filter it with anything?