Teradata Package for Python Function Reference on VantageCloud Lake - call_udf - Teradata Package for Python - Look here for syntax, methods and examples for the functions included in the Teradata Package for Python.

Teradata® Package for Python Function Reference on VantageCloud Lake

Deployment
VantageCloud
Edition
Lake
Product
Teradata Package for Python
Release Number
20.00.00.11
Publication Date
August 2026
Content Type
Programming Reference
Publication ID
B700-4500-200K
ft:locale
en-US
ft:lastEdition
2026-08-13
ft:sourceId
FTML
dita:id
TeradataPython_FxRef_Lake_2000
Product Category
Teradata Vantage
teradataml.dataframe.functions.call_udf = call_udf(udf_name, func_args=(), **kwargs)
DESCRIPTION:
    Call a registered user defined function (UDF).
 
PARAMETERS:
    udf_name:
        Required Argument.
        Specifies the name of the registered user defined.
        Types: str
        
    func_args:
        Optional Argument.
        Specifies the arguments to pass to the registered UDF.
        Default Value: ()
        Types: tuple
 
    delimiter:
        Optional Argument.
        Specifies a delimiter to use when reading columns from a row and
        writing result columns.
        Notes:
            * This argument cannot be same as "quotechar" argument.
            * This argument cannot be a newline character.
            * Use a different delimiter if categorial columns in the data contains
              a character same as the delimiter.
        Default Value: ','
        Types: one character string  
 
    quotechar:
        Optional Argument.
        Specifies a character that forces input of the user function
        to be quoted using this specified character.
        Using this argument enables the Analytics Database to
        distinguish between NULL fields and empty strings.
        A string with length zero is quoted, while NULL fields are not.
        Notes:
            * This argument cannot be same as "delimiter" argument.
            * This argument cannot be a newline character.
        Default Value: None
        Types: one character string
    
RETURNS:
    ColumnExpression
 
RAISES:
    TeradataMLException
 
EXAMPLES:
    # Load the data to run the example.
    >>> load_example_data("dataframe", "sales")
 
    # Create a DataFrame on 'sales' table.
    >>> import random
    >>> dfsales = DataFrame("sales")
    >>> df = dfsales.assign(id = case([(df.accounts == 'Alpha Co', random.randrange(1, 9)),
    ...                           (df.accounts == 'Blue Inc', random.randrange(1, 9)),
    ...                           (df.accounts == 'Jones LLC', random.randrange(1, 9)),
    ...                           (df.accounts == 'Orange Inc', random.randrange(1, 9)),
    ...                           (df.accounts == 'Yellow Inc', random.randrange(1, 9)),
    ...                           (df.accounts == 'Red Inc', random.randrange(1, 9))]))
 
    # Example 1: Register and Call the user defined function to get the values upper case.
    >>> from teradataml.dataframe.functions import udf, register, call_udf
    >>> @udf
    ... def to_upper(s):
    ...     if s is not None:
    ...         return s.upper()
    >>>
    # Register the created user defined function with name "upper".
    >>> register("upper", to_upper)
    >>>
    # Call the user defined function registered with name "upper" and assign the 
    # ColumnExpression returned to the DataFrame.
    >>> res = df.assign(upper_col = call_udf("upper", ('accounts',)))
    >>> res
                  Feb    Jan    Mar    Apr  datetime  id   upper_col
    accounts                                                        
    Yellow Inc   90.0    NaN    NaN    NaN  17/01/04   4  YELLOW INC
    Alpha Co    210.0  200.0  215.0  250.0  17/01/04   2    ALPHA CO
    Jones LLC   200.0  150.0  140.0  180.0  17/01/04   5   JONES LLC
    Red Inc     200.0  150.0  140.0    NaN  17/01/04   3     RED INC
    Blue Inc     90.0   50.0   95.0  101.0  17/01/04   1    BLUE INC
    Orange Inc  210.0    NaN    NaN  250.0  17/01/04   4  ORANGE INC
    >>>
 
    # Example 2: Register and Call user defined function to get factorial of a number  
    #            and store the result in Integer type column.
    >>> from teradataml.dataframe.functions import udf, register
    >>> @udf(returns = INTEGER())
    ... def factorial(n):
    ...    import math
    ...    return math.factorial(n)
    >>>
    # Register the created user defined function with name "fact".
    >>> from teradatasqlalchemy.types import INTEGER
    >>> register("fact", factorial)
    >>>
    # Call the user defined function registered with name "fact" and assign the
    # ColumnExpression returned to the DataFrame.
    >>> res = df.assign(fact_col = call_udf("fact", ('id',)))
    >>> res
                  Feb    Jan    Mar    Apr  datetime  id  fact_col
    accounts                                                      
    Jones LLC   200.0  150.0  140.0  180.0  17/01/04   5       120
    Yellow Inc   90.0    NaN    NaN    NaN  17/01/04   4        24
    Red Inc     200.0  150.0  140.0    NaN  17/01/04   3         6
    Blue Inc     90.0   50.0   95.0  101.0  17/01/04   1         1
    Alpha Co    210.0  200.0  215.0  250.0  17/01/04   2         2
    Orange Inc  210.0    NaN    NaN  250.0  17/01/04   4        24
    >>>
 
    # Example 3: Register and Call the Python function to get the values upper case.
    >>> from teradataml.dataframe.functions import register, call_udf
    >>> def to_upper(s):
    ...     return s.upper()
    >>>
    # Register the created Python function with name "upper".
    >>> register("upper", to_upper, returns = VARCHAR(1024))
    >>>
    # Call the Python function registered with name "upper" and assign the 
    # ColumnExpression returned to the DataFrame.
    >>> res = df.assign(upper_col = call_udf("upper", ('accounts',)))
    >>> res
                  Feb    Jan    Mar    Apr  datetime  id   upper_col
    accounts                                                        
    Yellow Inc   90.0    NaN    NaN    NaN  17/01/04   4  YELLOW INC
    Alpha Co    210.0  200.0  215.0  250.0  17/01/04   2    ALPHA CO
    Jones LLC   200.0  150.0  140.0  180.0  17/01/04   5   JONES LLC
    Red Inc     200.0  150.0  140.0    NaN  17/01/04   3     RED INC
    Blue Inc     90.0   50.0   95.0  101.0  17/01/04   1    BLUE INC
    Orange Inc  210.0    NaN    NaN  250.0  17/01/04   4  ORANGE INC
    >>>