Search code examples
ksqldb

KSQL UDF access ROWPARTITION and similar information


I have a custom UDF that I can pass a struct to:

select my_udf(a.my_data) from MY_STREAM a;

What I would like to do, is pass all info from my stream to that custom UDF:

select my_udf(a) from MY_STREAM a;

That way I can access the row partition, time, offset, etc. Unfortunately, KSQL does not understand my intent:

SELECT column 'A' cannot be resolved

Any idea how I could work around this?


Solution

  • It's not possible to pass in a full row into a UDF, only columns, and a is the name of the stream, not a column name.

    You can change your UDF, to accept multiple parameters, eg, my_udf(my_data, ROWTIME, ROWPARTITION) to pass in an the needed metadata individually.