Snowflake snippets
How to write a Python stored procedure in directly Snowflake (using Snowpark)
Using the Snowpark feature of Snowflakes you can write stored procedure in Python. The following is a very simple example of a procedure defined directly in the workspace screen of Snowflake.
CREATE OR REPLACE PROCEDURE reverse_string(INPUT_STR STRING)
RETURNS STRING
LANGUAGE PYTHON
RUNTIME_VERSION = '3.8'
PACKAGES = ('snowflake-snowpark-python')
HANDLER = 'reverse_str'
AS
$$
def reverse_str(session,INPUT_STR):
inv=INPUT_STR[::-1]
return inv
$$;
CALL reverse_string('ABC');