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

Teradata® Package for Python User Guide

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

teradataml enables execution of user-defined Python functions on Database Engine 20 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 Database Engine 20 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 the 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 Database Engine 20, and store it as a runnable script.
  • list_udfs() - List all the UDFs registered in Database Engine 20.
  • call_udf() - Execute the registered UDF.
  • deregister() - Delete the registered UDF from Database Engine 20.

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.
  • Do not run UDFs on the array columns.