Factory Function

The factory function consists of an R list which specifies the parameters of your R UDx.

Example

FunctionNameFactory <- function() { 
  list(name                  = MainFunctionName,
       udxtype               = c("scalar"),
       intype                = c("float","int", ...),
       outtype               = c("float", ...),
       outtypecallback       = MyReturnTypeFunc,
       parametertypecallback = MyParamReturnFunc,
       volatility            = c("volatile"), 
       strictness            = c("called_on_null_input") )
}

Arguments

name

The name of the R function in this User-Defined Extenstion (UDx) that is called when the function is invoked by Vertica and which returns the value(s) back to Vertica.

udxtype

The type of User-Defined Extension (UDx).

Valid Values:

  • scalar
  • transform
intype

The data type(s) of arguments accepted by the function. UDxs can have up to 1600 arguments.

See R and Vertica Data Types.

outtype

The data type(s) of the arguments returned by the function.

See R and Vertica Data Types.

outtypecallback

(Optional) The callback function to call before sending the data back to Vertica. It defines the types and precision that the main function returns.

For more information, see outtypecallback Function.

parametertypecallback

The callback function to send parameter types and names to Vertica.

This parameter is required if your UDx is called from Vertica with USING PARAMETERS.

For more information, see parametertypecallback Function.

volatility

(Optional) Indicates whether the function returns the same output given the same input, can be one of three types.

See Setting Null Input and Volatility Behavior for R Functions.

Default Value: VOLATILE

strictness

(Optional) Indicate whether the function always returns NULL when any of its input arguments is NULL.

See Setting Null Input and Volatility Behavior for R Functions.

Default Value: CALLED_ON_NULL_INPUT

Description

User-Defined Functions in R (R UDx) require a factory function for each main R function that you want to call from within Vertica. The factory function encapsulates all the information required by Vertica to load the R UDx.