Vertica Analytics Platform Version 9.2.x Documentation

CREATE TRANSFORM FUNCTION

Adds a user-defined transform function (UDTF) stored in a shared Linux library to the catalog. You must have already loaded this library using the CREATE LIBRARY statement. When you call the SQL function, Vertica passes the input table to the transform function in the library to process.

CREATE TRANSFORM FUNCTION automatically determines the parameters and return value for the function from data supplied by the factory class.

Vertica supports overloading transform functions.

Syntax

CREATE [OR REPLACE] TRANSFORM FUNCTION function‑name 
    AS [LANGUAGE 'language' ] NAME 'factory' 
    LIBRARY library‑name
    [ FENCED | NOT FENCED ]

Parameters

OR REPLACE If you omit this parameter, the CREATE TRANSFORM FUNCTION statement fails if an existing function matches the name and parameters of the function you are trying to define. If you supply this parameter, the new function definition overwrites the old one.
function‑name

The name to assign to the UDTF. This is the name you use in your SQL statements to call the function.

LANGUAGE 'language'

The language used to develop this function, one of the following:

  • C++ (default)
  • Java
  • R
  • PYTHON
NAME 'factory'

The name of the factory class or R factory function in the shared library that generates the object to handle the function's processing.

LIBRARY library‑name

The name of the shared library that contains the object to perform the processing for this function. This library must have been previously loaded using the CREATE LIBRARY statement.

FENCED | NOT FENCED

Enables or disables Fenced Mode for this function. Functions written in R always run in fenced mode.

Default Value: FENCED

Privileges

Non-superuser:

  • CREATE privilege on the function's schema
  • USAGE privilege on the function's library

UDTF Query Restrictions

A query that includes a UDTF cannot contain:

Examples

This example shows how to add a UDTF to the catalog.

=> CREATE TRANSFORM FUNCTION transFunct AS LANGUAGE 'C++' NAME 'myFactory' LIBRARY myFunction;

See Also