0% found this document useful (0 votes)
27 views

Creating Stored Procedures For DataFrames in Python - Snowflake Documentation

The document discusses how to create stored procedures for DataFrames in Python using the Snowpark API. It covers creating both temporary and permanent stored procedures, using third-party packages from Anaconda, and provides an example of importing packages and returning their versions in a stored procedure.

Uploaded by

demorepo99
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
27 views

Creating Stored Procedures For DataFrames in Python - Snowflake Documentation

The document discusses how to create stored procedures for DataFrames in Python using the Snowpark API. It covers creating both temporary and permanent stored procedures, using third-party packages from Anaconda, and provides an example of importing packages and returning their versions in a stored procedure.

Uploaded by

demorepo99
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

4/29/24, 3:05 PM Creating Stored Procedures for DataFrames in Python | Snowflake Documentation

Developer Snowpark API Python Creating Stored Procedures for DataFrames


Creating Stored Procedures for
DataFrames in Python
The Snowpark API provides methods that you can use to create a stored procedure
in Python. This topic explains how to create stored procedures.
Introduction
With Snowpark, you can create stored procedures for your custom lambdas and
functions, and you can call these stored procedures to process the data in your
DataFrame.
You can create stored procedures that only exist within the current session
(temporary stored procedures) as well as stored procedures that you can use in
other sessions (permanent stored procedures).
Using Third-Party Packages from Anaconda in a
Stored Procedure ¶
You can specify Anaconda packages to install when you create Python stored
procedures. When calling the Python stored procedure inside a Snowflake
warehouse, Anaconda packages are installed seamlessly and cached on the virtual
warehouse on your behalf. For more information about best practices, how to view
the available packages, and how to set up a local development environment, see
Using Third-Party Packages.
Use session.add_packages to add packages at the session level.
This code example shows how to import packages and return their versions.
>>> import pandas as pd
>>> import snowflake.snowpark
>>> import xgboost as xgb
>>> from snowflake.snowpark.functions import sproc

>>> session.add_packages("snowflake-snowpark-python", "pandas", "xgbo

>>> @sproc
... def compute(session: snowflake.snowpark.Session) -> list:
... return [pd.__version__, xgb.__version__]

https://docs.snowflake.com/en/developer-guide/snowpark/python/creating-sprocs 1/1

You might also like