- DBC user cannot be used for creating UDFs. Create a different user for this purpose.
- The DBA must grant users the necessary privileges to create UDFs in VantageCloud Lake:
- GRANT CREATE FUNCTION, DROP FUNCTION ON database_name TO username;
- GRANT LOGON ON ALL TO username WITH NULL PASSWORD;
- GRANT ALL ON SQLJ TO username;
- The Teradata External Routine Installation Tool (tdextroutine) must be installed on your local system. See Installing the External Routine Installation Tool.
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 the syntax to tdextroutine calls for use with VantageCloud Lake. See Migrating Existing SQL Scripts to VantageCloud Lake.
Otherwise, follow these steps to create a C/C++ or Java UDF in VantageCloud Lake.
- Place your C/C++ or Java UDF source files or object file in a source directory.
- Create a manifest.json file that contains a listing of all external files related to the UDF as well as properties that define the UDF. See UDF Manifest File.
- Place the manifest.json file in the source directory together with your C/C++ or Java UDF source files or object file.
- Use tdextroutine with the udf create subcommand to create the UDF.tdextroutine -k your_org_name -n your_account_name -u your_username udf create -s path_to_source_directory -d database_to_contain_your_UDF UDF_function_nameImportant:
Do not create UDFs in Teradata system databases such as SYSLIB or SYSUDTLIB unless directed to do so. For example, UDFs used for row level security must reside in the SYSLIB database.
- Do not use DBC user to create UDFs.
Tip: You can use environment variables to specify the options for tdextroutine. You can also create a config YAML file to define the defaults for the options. - Use GRANT to grant privileges to users who are authorized to use the UDF.
For details about the GRANT statement, see SQL Data Control Language.
For details of all tdextroutine options and environment variables, udf create subcommand options, and information about the config YAML file, see Specifying tdextroutine Options and Environment Variables and tdextroutine UDF Subcommands and Options.
For an example of creating a C UDF in VantageCloud Lake, see Example: Creating a C UDF.