teradataml enables execution of user defined Python functions on Analytics Database with simple interfaces so you can write these functions and mark/register them to be used as the UDF with teradataml DataFrame.
See teradataml UDF Prerequisites to configure Analytics Database to use the operator supported by your database version.
udf decorator
teradataml provides udf - Function decorator as a decorator to mark/register a UDF within a session.
UDF functions
Use udf decorator to convert any regular Python function to a teradataml UDF, but the scope of the teradataml UDF is limited to the session. You can work with a UDF to modify it in a session until it is finalized. Once the UDF is finalized and ready to be used over multiple sessions, use register() and call_udf() to store the teradataml UDF and execute the stored UDF.
- register() - Register the function in Analytics Database, and store it as a runnable script.
- list_udfs() - List all the UDFs registered in Analytics Database.
- call_udf() - Execute the registered UDF.
- deregister() - Delete the registered UDF from Analytics Database.
Considerations
- UDF functions must be used with DataFrame.assign() method. See udf() Examples.
- Lambda function are not supported. Re-write the lambda function as regular Python function to use with UDF.
- Do not run UDFs on the column names same as Teradata Reserved Keywords. Rename such column names using DataFrame.assign() and then use those columns.
- All Python objects used by the function, must be created/imported within the function.