Serialized string

The Serialize string channel is similar to the Workspace file channel. In this case, the user code is passed directly as the value of the CODE_SERIALIZED environment variable, without an intermediate file in the workspace directory. The file contains a serialized list and the string variable is also base64-encoded.

This list elements are:
  • Required: mode, fun, args.
  • Optional: shaper, shaper.args, columns, shaper.list, file.
The R code creating the contents of the CODE_SERIALIZED variable requires the caTools CRAN package:
x <- list(mode='run', args=list(), fun=function(){
getNext(); setOutput(0,'output value'); outputResult()})
base64encode(rawToChar(serialize(x, NULL, ascii=TRUE)))
The SQL query is presented in the example. Note that backslash signs denote a line continuation and should be omitted when pasting to nzsql:
SELECT * FROM TABLE WITH
FINAL(nzr..r_udtf('CODE_SERIALIZED=QQoyCjEzMzYzMwoxMzE\
4NDAKNTMxCjMKMTYKMQo5CjMKcnVuCjE5CjAKMTUzOQoxMDI2CjEKO\
Qo2CnNvdXJjZQoxNgoxCjkKNjYKZnVuY3Rpb24oKXtnZXROZXh0KCk\
7XDA0MHNldE91dHB1dCgwLFwnb3V0cHV0XDA0MHZhbHVlXCcpO1wwN\
DBvdXRwdXRSZXN1bHQoKX0KMjU0CjI1MwoyNTQKNgoxCjkKMQp7CjI\
KNgoxCjkKNwpnZXROZXh0CjI1NAoyCjYKMQo5CjkKc2V0T3V0cHV0C\
jIKMTQKMQowCjIKMTYKMQo5CjEyCm91dHB1dFwwNDB2YWx1ZQoyNTQ\
KMgo2CjEKOQoxMgpvdXRwdXRSZXN1bHQKMjU0CjI1NAoxMDI2CjEKO\
Qo1Cm5hbWVzCjE2CjMKOQo0Cm1vZGUKOQo0CmFyZ3MKOQozCmZ1bgo\
yNTQKAA=='))
When passed in a SQL console should once again result in:
COLUMNID | VALUE
----------+--------------
0 | output value
(1 row)