User-Defined Function (UDF) object
User-Defined Function (UDF) object
... | Arguments passed on to
|
---|
UDF objects store the definition of a user-defined function along with metadata and unit tests.
new()
Initialize a udf
object
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(), ... )
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)
write()
Write UDF definition file
udf$write(file, ...)
create()
Load a user-defined function
udf$create(conn, test = TRUE)
drop()
Drop (delete) UDF
udf$drop(conn, cascade = FALSE)
test()
Run tests
udf$test(conn)
clone()
The objects of this class are cloneable with this method.
udf$clone(deep = FALSE)
deep
Whether to make a deep clone.