This very simple example fails in Snowflake:
CREATE OR REPLACE PROCEDURE example_procedure()
RETURNS TABLE (example_col STRING)
LANGUAGE SQL
AS
$$
DECLARE
res resultset;
BEGIN
WITH sample_cte AS (
SELECT 'data' AS example_col
)
res := SELECT example_col FROM sample_cte;
return table(res);
END;
$$;
The error is confusing:
Syntax error: unexpected 'sample_cte'. (line 5)
syntax error line 5 at position 20 unexpected 'AS'. (line 5)
I’d really like to avoid building a query string and then execute immediate :query
since it seems like this should work.