I utilized the Snowpark Python (private preview) to do some data engineering tasks (transform the data from a raw state to a clean state). How do I upload the Python code to Snowflake to then run it?
I think it needs to be a stored procedure but I can not find any documentation on how to create a stored procedure in Python.
Snowpark Stored Procedures for Python — Preview was released in June 2022.
Documentation is available at Writing Stored Procedures in Snowpark (Python)
Example:
In an in-line stored procedure, you write your Python code in the AS clause of the CREATE PROCEDURE statement. For example:
CREATE OR REPLACE PROCEDURE MYPROC(from_table STRING, to_table STRING, count INT) RETURNS STRING LANGUAGE PYTHON RUNTIME_VERSION = '3.8' PACKAGES = ('snowflake-snowpark-python') HANDLER = 'run' AS $$ def run(session, from_table, to_table, count): session.table(from_table).limit(count).write.save_as_table(to_table) return "SUCCESS" $$;