UDF output sizer examples
Example #1
This code creates a UDF that takes two strings of any length and returns the result of
concatenating the strings together. The calculateSize() method is used to determine the size of the
result. The calculateSize() method will always be called when the result type of a UDF is defined as
varchar(any) or numeric(any). UDA and UDTF do not support the calculateSize()
method.
function evaluate(s1, s2 )
return s1 || s2
end
function calculateSize( args )
return args[1].length + args[2].length
end
function getType()
return "UDF"
end
function getName()
return "concat"
end
function getArgs()
return {{ "", varchar("any") },
{ "", varchar("any") }}
end
function getResult()
return varchar(any)
end