register() function registers a Python function or teradataml udf and stores it in Database Engine 20 for future use. This makes the function reusable across sessions, unlike udf - Function decorator, which is limited to a single session.
Registered UDFs are stored in Database Engine 20 as a runnable Python script, which is executed using the Script table operator or Apply table operator. See teradataml UDF Prerequisites.
When working with Open Analytics Framework, registered UDFs are stored in either the default user environment or the environment specified by the user in the configuration option.
Registered UDFs are stored in the file system or user environment with the naming convention as tdml_udf_name_<registered udf name>_udf_type_<return type>_register.py.
Be careful when deleting these files directly.
Arguments
| Argument | Required/Optional | Type | Description |
|---|---|---|---|
| name | Required | string | Specifies the name of the user defined function to register. |
| user_function | Required | function, teradataml udf | Specifies the user defined function to create a column for teradataml DataFrame. |
| returns | Optional | teradatasqlalchemy types object | Specifies the output column type. When not specified, default is VARCHAR(1024). If 'user_function' is a teradataml udf, then return type of the udf is used as return type of the registered UDF. |