User-Defined Table Functions¶
User-defined table functions (UDTFs) in Snowpark. Please see Python UDTF for details. There is also vectorized UDTF. Compared to the default row-by-row processing pattern of a normal UDTF, which sometimes is inefficient, vectorized Python UDTFs (user-defined table functions) enable seamless partition-by-partition processing by operating on partitions as pandas DataFrames (https://pandas.pydata.org/docs/reference/api/pandas.DataFrame.html) and returning results as pandas DataFrames (https://pandas.pydata.org/docs/reference/api/pandas.DataFrame.html) or lists of pandas arrays (https://pandas.pydata.org/docs/reference/api/pandas.array.html) or pandas Series (https://pandas.pydata.org/docs/reference/series.html).
In addition, vectorized Python UDTFs allow for easy integration with libraries that operate on pandas DataFrames or pandas arrays.
- A vectorized UDTF handler class:
- defines an - end_partitionmethod that takes in a DataFrame argument and returns a- pandas.DataFrameor a tuple of- pandas.Seriesor- pandas.arrayswhere each array is a column.
- does NOT define a - processmethod.
- optionally defines a handler class with an - __init__method which will be invoked before processing each partition.
 
Note
A vectorized UDTF must be called with partition_by() to build the partitions.
Refer to UDTFRegistration for details and sample code on how to create regular and vectorized UDTFs using Snowpark Python API.
Classes
| 
 | Provides methods to register classes as UDTFs in the Snowflake database. | 
| 
 | Encapsulates a user defined table function that is returned by  | 
Methods
| 
 | Registers a Python class as a Snowflake Python UDTF and returns the UDTF. | 
| 
 | Registers a Python class as a Snowflake Python UDTF from a Python or zip file, and returns the UDTF. | 
Attributes
| The Python class or a tuple containing the Python file path and the function name. | |
| The UDTF name. |