Plain string
The Plain string channel is designed for scenarios where R code must be embedded in SQL.
The default running mode is run; however, it can be overridden by setting the MODE
environment variable. The code is passed as the value of the CODE_PLAIN
environment
variable. An additional environment variable, SHAPER_LIST
, can be used to pass also
the output signature.
SELECT * FROM TABLE WITH FINAL(nzr..r_udtf('CODE_PLAIN=\
"getNext();setOutput(0,''output value'');outputResult()"'))
COLUMNID | VALUE
----------+--------------
0 | output value
(1 row)
SELECT * FROM TABLE WITH FINAL(nzr..r_udtf('CODE_PLAIN=
"getNext();setOutput(0,''output value'');outputResult()",
SHAPER_LIST="value=list(NZ.VARIABLE,32)"'))
which results in the same output as previous
examples:value
--------------
output value
(1 row)
The SHAPER_LIST
environment variable should contain the comma-separated entries
in the form column name=data type
. For character columns (variable and fixed), the
data type must take the following form: list(NZ.DATATYPE,length)
. For other data
types it is the data type identifier only.