C++ UDF in vertica
I need to write a UDF in C++ for the vertica DB.
The UDF is applied on every row. It takes an integral input and returns an array of indexes with the set bit. Ex: UDF's input and output
Input --> Output
0 --> { }
7 --> { '0', '1', '2' }
1 --> { '0' }
5 --> { '0', '2' }
11 --> { '0', '2', '4' }
I read about various types of UDFs in vertica. I think for my use case I need to use scalar functions.
The output is an array of strings.
But I am unable to figure out what vertica datatype should I return as output. The vertica document do not mention of any array data types.
Please correct me if I am wrong.
0
Answers
Hi Anshuman,
The SDK doesn't support array data types. You could use a UD transform to output an arbitrary number of columns from the UDx. You'd need to decide on the largest number of indexes your UDx could output beforehand.
A more efficient option could be to encode the array output in a Varbinary value. In such case you could use a UDSF. This could be useful if you plan to pass around this output to another function that will decode the array value.
Ariel