User-Defined Function (UDF) object

User-Defined Function (UDF) object

Arguments

...

Arguments passed on to yaml::write_yaml

x

the object to be converted

file

either a character string naming a file or a connection open for writing

fileEncoding

character string: if non-empty declares the encoding to be used on a file (not a connection) so the character data can be re-encoded as they are written. See file.

Details

UDF objects store the definition of a user-defined function along with metadata and unit tests.

Methods

Public methods


Method new()

Initialize a udf object

Usage

udf$new(
  name,
  version,
  returns,
  volatility = c("volatile", "stable", "immutable"),
  language = c("sql", "plpythonu"),
  params = list(),
  body,
  description,
  schema = NA,
  replace = FALSE,
  authors = list(),
  tests = list(),
  ...
)

Arguments

name

The UDF's name (e.g., "f_calculate_stuff")

version

A version string (e.g., "1.0")

returns

Data type returned by this UDF (e.g., "float")

volatility

Given the same inputs, the function will always return the same result ("immutable"), will return the same result during a given statement ("stable"), may return different results on successive calls ("volatile").

language

String indicating the language used for the UDF's body (e.g., "sql")

params

A list of zero or more udfparameter objects specifying input parameters

body

The body of the UDF containing SQL, Python, or other supported language

description

A detailed description of the UDF

schema

Database schema in which to place UDF (defualt: NA)

replace

Logical value indicating whether existing versions should be replaced (default: FALSE)

authors

List of authors (e.g., list("Jane Doe"))

tests

A list of zero or more udftest objects specifying test cases for this UDF

...

Additional arguments (not used)


Method write()

Write UDF definition file

Usage

udf$write(file, ...)


Method create()

Load a user-defined function

Usage

udf$create(conn, test = TRUE)


Method drop()

Drop (delete) UDF

Usage

udf$drop(conn, cascade = FALSE)


Method test()

Run tests

Usage

udf$test(conn)


Method clone()

The objects of this class are cloneable with this method.

Usage

udf$clone(deep = FALSE)

Arguments

deep

Whether to make a deep clone.