Plain R file
The Plain R file channel is designed to work interactively with R and SQL. The user
function and any additional data are stored in a plain-text file and directly named by the
PLAIN_PATH environment variable. The difference is that the object names must
contain the prefix nz., that is, nzdot.
The following objects are supported:
- Required:
nz.mode(defaults torun),nz.fun. - Optional:
nz.shaper,nz.shaper.args,nz.cols,file.
The following listing is an example of a plain R file:
nz.mode <- 'run'
nz.fun <- function() {
getNext()
setOutput(0,'output value')
outputResult()
}If saved as /home/nz/plain_r this code can be invoked with the following
query:
SELECT * FROM TABLE WITH FINAL(nzr..r_udtf('PLAIN_PATH=/home/nz/plain_r'));
which results in:COLUMNID | VALUE
----------+--------------
0 | output value
(1 row)