R language simple table function conversion
The code from the R language scalar function 1 can be reused as a simple table function by making minor modifications to the registration.
Code
The code is the same as in R language scalar function 1.
Compilation
The compilation is the same as the one that is done in local or remote modes.
Registration
Register the executables by using the modified command, changing
--template and
--return to be appropriate for a table
function:/nz/export/ae/utilities/bin/register_ae --language r --version 3 \
--template udtf --exe applyop.R --sig "tapplyop_r(VARARGS)" \
--return "TABLE(RESULT INT4)" --db dev --user nzRunning
You can now run the AE in SQL as
follows:
SELECT * FROM TABLE WITH FINAL(tapplyop_r('+',1,2));
RESULT
--------
3
(1 row)