Snowflake has recently released the Snowflake Python Worksheets which is in public preview at present. This will make it much easier than ever to integrate Snowpark Python directly into your Snowflake environment.
In this article, we will cover on how to set up your Python worksheets, write Python code, run it efficiently, and deploy it as a stored procedure within your Snowflake environment.
What if you can’t find the package in the Snowflake Anaconda? Or, you have created a custom Python file or package and wanted to import into your Snowflake worksheet? Below is the steps to import custom packages:
Step 1 – In the worksheet tab, under the “Packages”, select “Stage Packages” and import the required Python file or package which is stage location.
For example, @YourStage/path/to/package.py
Step 2 – Now, select Import to add your package to the list of installed packages. You can now use import statements to use the package in your Python worksheet.
Step 1 – On the right-hand corner of the worksheet, click on the “Deploy” and input stored procedure name. Then, click on the Deploy button to create as a Snowflake Stored Procedure.
Step 2 – Call the Stored Procedure as below once it is created successfully.
Command: CALL TEST_DB1.PUBLIC.SAMPLE_EMPDATA ()
Step 3 – Now, you have successfully deployed your python script as a Snowflake Stored Procedure.
Snowflake Python Worksheets are a game-changing feature that was just recently made available to public preview. These worksheets made easier and faster to execute your Python code in the Snowflake environment. It also comes with features that support Snowpark and other third-party libraries. On top of that, it also supports IntelliSense with auto-complete, making it even easier to use.
In this article, we covered all the essentials related to Snowflake Python Worksheets. We discussed how to prepare roles and packages, set up your Python worksheet, wrote a Python script, ran it efficiently, and deployed it as a Stored Procedure with just one click.