teradataml UDF | Teradata Package for Python - teradataml UDF - Teradata Package for Python

Teradata® Package for Python User Guide

Deployment
VantageCloud
VantageCore
Edition
Enterprise
IntelliFlex
VMware
Product
Teradata Package for Python
Release Number
20.00
Published
December 2024
ft:locale
en-US
ft:lastEdition
2025-01-23
dita:mapPath
nvi1706202040305.ditamap
dita:ditavalPath
plt1683835213376.ditaval
dita:id
rkb1531260709148
Product Category
Teradata Vantage

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.

To work with the stored UDFs, teradataml provides following set of UDF functions:
  • 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.