snowflake.snowpark.udaf.UDAFRegistration.register¶
- UDAFRegistration.register(handler: Type, return_type: Optional[DataType] = None, input_types: Optional[List[DataType]] = None, name: Optional[Union[str, Iterable[str]]] = None, is_permanent: bool = False, stage_location: Optional[str] = None, imports: Optional[List[Union[str, Tuple[str, str]]]] = None, packages: Optional[List[Union[str, module]]] = None, replace: bool = False, if_not_exists: bool = False, parallel: int = 4, external_access_integrations: Optional[List[str]] = None, secrets: Optional[Dict[str, str]] = None, comment: Optional[str] = None, copy_grants: bool = False, *, statement_params: Optional[Dict[str, str]] = None, source_code_display: bool = True, immutable: bool = False, **kwargs) UserDefinedAggregateFunction[source]¶
Registers a Python function as a Snowflake Python UDAF and returns the UDAF. The usage, input arguments, and return value of this method are the same as they are for
udaf(), butregister()cannot be used as a decorator. See examples inUDAFRegistrationand notes inudaf().- Parameters:
handler – A Python class used for creating the UDAF.
return_type – A
DataTyperepresenting the return data type of the UDAF. Optional if type hints are provided.input_types – A list of
DataTyperepresenting the input data types of the UDAF. Optional if type hints are provided.name – A string or list of strings that specify the name or fully-qualified object identifier (database name, schema name, and function name) for the UDAF in Snowflake, which allows you to call this UDAF in a SQL command or via
agg()orgroup_by(). If it is not provided, a name will be automatically generated for the UDAF. A name must be specified whenis_permanentisTrue.is_permanent – Whether to create a permanent UDAF. The default is
False. If it isTrue, a validstage_locationmust be provided.stage_location – The stage location where the Python file for the UDAF and its dependencies should be uploaded. The stage location must be specified when
is_permanentisTrue, and it will be ignored whenis_permanentisFalse. It can be any stage other than temporary stages and external stages.imports – A list of imports that only apply to this UDAF. You can use a string to represent a file path (similar to the
pathargument inadd_import()) in this list, or a tuple of two strings to represent a file path and an import path (similar to theimport_pathargument inadd_import()). These UDAF-level imports will override the session-level imports added byadd_import(). Note that an empty list means no import for this UDAF, andNoneor not specifying this parameter means using session-level imports.packages – A list of packages that only apply to this UDAF. These UDAF-level packages will override the session-level packages added by
add_packages()andadd_requirements(). Note that an empty list means no package for this UDAF, andNoneor not specifying this parameter means using session-level packages. To use Python packages that are not available in Snowflake, refer tocustom_package_usage_config().replace – Whether to replace a UDAF that already was registered. The default is
False. If it isFalse, attempting to register a UDAF with a name that already exists results in aSnowparkSQLExceptionexception being thrown. If it isTrue, an existing UDAF with the same name is overwritten.if_not_exists – Whether to skip creation of a UDAF when one with the same signature already exists. The default is
False.if_not_existsandreplaceare mutually exclusive and aValueErroris raised when both are set. If it isTrueand a UDAF with the same signature exists, the UDAF creation is skipped.parallel – The number of threads to use for uploading UDAF files with the PUT command. The default value is 4 and supported values are from 1 to 99. Increasing the number of threads can improve performance when uploading large UDAF files.
statement_params – Dictionary of statement level parameters to be set while executing this action.
source_code_display – Display the source code of the UDAF func as comments in the generated script. The source code is dynamically generated therefore it may not be identical to how the func is originally defined. The default is
True. If it isFalse, source code will not be generated or displayed.immutable – Whether the UDAF result is deterministic or not for the same input.
external_access_integrations – The names of one or more external access integrations. Each integration you specify allows access to the external network locations and secrets the integration specifies.
secrets – The key-value pairs of string types of secrets used to authenticate the external network location. The secrets can be accessed from handler code. The secrets specified as values must also be specified in the external access integration and the keys are strings used to retrieve the secrets using secret API.
comment – Adds a comment for the created object. See COMMENT
copy_grants – Specifies to retain the access privileges from the original function when a new function is created using CREATE OR REPLACE FUNCTION.
See also