Main function

The first function called when Vertica runs an R user-defined extension (UDx).

The first function called when Vertica runs an R user-defined extension (UDx). It must return a data frame and is defined by the name parameter of the factory function.

Example

FunctionName <- function(input_data_frame, parameters_data_frame) {
  # Each column from Vertica is turned into a column in the input data frame.
  # This is a brief example of multiplying two columns of the input data frame.
  output_data_frame <- data.frame(input_data_frame[, 1] * input_data_frame[, 2])
  # The function must return a data frame.
  return(output_data_frame)
}

Arguments

input_data_frame The data read by the Vertica user-defined extension (UDx). This input must be a data frame.
parameters_data_frame

The parameters passed to the Vertica user-defined extension (UDx).

This input must be a data frame. If you are passing parameters from your Vertica UDx, defined with USING PARAMETERS, then you must included this in your R UDx. If you are not passing parameters to your R UDx, then this can be omitted from your R UDx.

Description

The main function takes as input one data frame as the first argument, and if your UDx accepts parameters, a parameter data frame as the second argument. The main function must return a data frame. The factory function converts the intype argument into a data frame for the main function. For example, intype=c("float","float") is converted by the factory function into a two-dimensional matrix.

The function can call other functions defined in your R UDx library file.