I am using session windows in Flink SQL (1.13).
Is there a way (must be in SQL, no UDFs etc.) to get the last value of a certain field (in other words: this would be a value at window_end
)?
I was trying with:
SELECT user_account_id,
SESSION_START(request_timestamp, INTERVAL '30' MINUTE) AS window_start,
SESSION_END(request_timestamp, INTERVAL '30' MINUTE) AS window_end,
LAST_VALUE(package)
GROUP BY SESSION(request_timestamp, INTERVAL '30' MINUTE), user_account_id
but I am getting error:
Could not find an implementation method 'merge' in class 'org.apache.flink.table.planner.functions.aggfunctions.LastValueAggFunction' for function 'LAST_VALUE' that matches the following signature:
void merge(org.apache.flink.table.data.RowData, java.lang.Iterable)
I guess that using window functions (OVER(...)
) would not work here.
Any hints appreciated!
I've got the answer that this is not supported yet. A workaround would be to create a custom user-defined aggregate function (UDAGG) . Apart from that, there is a new Jira for that functionality.