Creating UDFs | VantageCloud Lake - Creating UDFs - Teradata Vantage

Teradata® VantageCloud Lake

Deployment
VantageCloud
Edition
Lake
Product
Teradata Vantage
Published
January 2023
ft:locale
en-US
ft:lastEdition
2024-12-11
dita:mapPath
phg1621910019905.ditamap
dita:ditavalPath
pny1626732985837.ditaval
dita:id
phg1621910019905

A UDF is similar to standard SQL functions such as SQRT, ABS, or TRIM and is invoked in the same manner.

You can write UDFs using these programming languages:
  • SQL
  • C or C++
  • Java
After your C/C++ UDFs are compiled into shared objects, you can use the UDFs in SQL statements. Similarly, after your Java UDF is installed in the database, you can use the UDF like a standard SQL function.

Teradata supports these types of UDFs:

UDF Type Description
Scalar Takes input arguments and returns a single value result.
Aggregate Takes grouped sets of relational data, makes a pass over each group, and returns one result for the group.
Table Function Invoked in the FROM clause of an SQL SELECT statement.

Returns a table a row at a time to the SELECT statement. Can produce the rows of a table from input arguments or by reading an external file or message queue.

Table Operator Invoked in the FROM clause of an SQL SELECT statement.

Accepts one or more tables or table expressions as input and generates a table as output.

Scalar UDFs, aggregate UDFs, and table operators can run on the primary cluster or on compute clusters.

  • C, C++ and Java UDFs can run on both the compute cluster and the primary cluster.
  • Table functions only run on the primary cluster and are not supported on the compute clusters.

Creating and Managing SQL UDFs

Use the SQL user-defined function statements such as CREATE FUNCTION and DROP FUNCTION to create and manage SQL UDFs. For details, see:

Creating and Managing C, C++, or Java UDFs

Use the External Routine Installation Tool (tdextroutine) to create and manage C/C++ or Java UDFs.

If you have SQL scripts (BTEQ files) that use the CREATE/REPLACE FUNCTION syntax to create C/C++ or Java UDFs, use the External Routine Migration Tool (XRMigrationTool) to convert this syntax to tdextroutine calls for use with VantageCloud Lake.

For example, if you have existing SQL scripts that create C/C++ or Java UDFs for VantageCloud Enterprise or VantageCore, you must migrate the scripts to VantageCloud Lake using XRMigrationTool.