CREATE ANALYTIC FUNCTION

Adds to the catalog a user-defined analytic function (UDAnF) that is stored in a shared Linux library. CREATE ANALYTIC FUNCTION automatically determines the function parameters and return value from data supplied by the factory class. Vertica supports overloading analytic functions. When you call the SQL function, Vertica passes the input table to the function in the library to process.

Syntax

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

Parameters

OR REPLACE

Specifies to overwrite an existing function of the same name and matching arguments; otherwise the CREATE statement returns with a rollback error.

function‑name

Identifies the function to create, where function conforms to conventions described in Identifiers.

This name does not need to match the name of the factory, but it is less confusing if they are the same or similar.

LANGUAGE 'language'

Language used to develop this function, one of the following:

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

Name of the C++ factory class in the shared library that generates the object to handle function processing.

LIBRARY library

Name of the shared library that contains the C++ object to process this function. This library must already be loaded by CREATE LIBRARY.

FENCED | NOT FENCED

Enables or disables fenced mode for this function.

Default: 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)