I am implementing custom library (using UDFs) for KSQL engine and I wonder how to solve one of the issues I have.
I have defined a couple of UDFs which do something with parameters passed and return some output. Now, I need to pass those UDFs (their calls) into other UDF. So the structure would look like this:
SELECT * FROM stream s WHERE UDF_1(UDF_11(s.param1, s.param2), UDF_12(s.param3, s.param4), ...) EMIT CHANGES;
Is it possible to do define the UDF which takes other UDFs as arguments? If yes, how can I achieve it? If not, please share the idea you have on how I can solve the problem.
Thanks for any help in advance.
I'm assuming you're asking about what the parameters for the method definition should be?
A UDF would return a single value, and the functions would be evaluated inside out, so they are not "taking UDFs as parameters", just the return value, which would generally be a primitive java type
For example, if you split a string column, then cast it to an int, that'd have to look like CAST(STRSPLIT(c, delim)[0] AS INT)
, where the cast operator takes any Object (here a string), and returns an integer, which could be passed further to more UDFs