UDTF output shaper examples
Example #1
This simple UDTF splits a input string into multiple output strings based on the a delimiter
string. The number of columns and the column names returned by this UDTF are determined at runtime
based on the third parameter, which must be a constant value. To activate the runtime call to the
calculateShape() method the getShape() method of the UDTF must return the ANYSHAPE
constant.
function processRow(str,delim,columns)
return { split(str,delim) }
end
function calculateShape(arg)
local maxcols = arg[3].value
local cols = {}
for i=1,maxcols do
cols[i] = { "S"||i, "varchar", 255 }
end
return cols
end
function getType()
return "udtf"
end
function getName()
return "nzlua_split"
end
function getArgs() },
return {{"", varchar(any)
{"", char(1) },
{"", integer }}
end
function getShape()
return ANYSHAPE
end