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 and returning results as Pandas DataFrames or lists of Pandas arrays or Pandas Series.
In addition, vectorized Python UDTFs allow for easy integration with libraries that operate on pandas DataFrames or pandas arrays.
- A vectorized UDTF handler class:
end_partitionmethod that takes in a DataFrame argument and returns a
pandas.DataFrameor a tuple of
pandas.arrayswhere each array is a column.
does NOT define a
optionally defines a handler class with an
__init__method which will be invoked before processing each partition.
A vectorized UDTF must be called with
partition_by() to build the partitions.
UDTFRegistration for details and sample code on how to create regular and vectorized UDTFs using Snowpark Python API.
Provides methods to register classes as UDTFs in the Snowflake database.
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.
The Python class or a tuple containing the Python file path and the function name.
The UDTF name.