Vertica Analytics Platform Version 9.2.x Documentation

CREATE ANALYTIC FUNCTION

Associates a user-defined analytic function (UDAnF) stored in a shared Linux library with a SQL function name. You must have already loaded the library containing the UDAnF using the CREATE LIBRARY statement. When you call the SQL function, Vertica passes the arguments to the analytic function in the library to process.

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

Vertica supports overloading analytic functions.

Syntax

CREATE [ OR REPLACE ] ANALYTIC FUNCTION function-name 
... AS [ LANGUAGE 'language' ] NAME 'factory' 
... LIBRARY library_name
... [ FENCED | NOT FENCED ];

Parameters

function‑name

The name to assign to the UDAnF. 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
NAME 'factory'

The name of the C++ factory class 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 C++ 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.

Default Value: FENCED

Privileges

Non-superuser:

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

Examples

This example shows how to create an analytic function named an_rank based on the factory class named RankFactory in the AnalyticFunctions library..

=> CREATE ANALYTIC FUNCTION an_rank AS LANGUAGE 'C++'
   NAME 'RankFactory' LIBRARY AnalyticFunctions;

See Also

Analytic Functions (UDAnFs)