0
votes

My typical use case is to keep monitoring an event stream to detect event patterns, but I expect the window is a hopping one. By default, interval ... in CEP SQL should define a tumbling window. Is it possible to have a hopping window for CEP pattern matching? or any other solutions?

Thanks

2

2 Answers

2
votes

It is possible to nest time-based queries in Flink SQL. So you can define a MATCH_RECOGNIZE clause on a view that did a windowing before.

Here is some sketch example:

-- get the rowtime from the window operation
CREATE TEMPORARY VIEW my_view AS
  SELECT HOP_ROWTIME(rowtime, INTERVAL '1' SECOND, INTERVAL '2' SECOND) AS windowedRowtime, ...
  FROM my_table
  GROUP BY HOP(rowtime, INTERVAL '1' SECOND, INTERVAL '2' SECOND);

-- use the new rowtime for MATCH_RECOGNIZE
SELECT * FROM my_view MATCH_RECOGNIZE(ORDER BY windowedRowtime ...)
1
votes

If by "Flink CEP SQL" you mean MATCH_RECOGNIZE, then the WITHIN INTERVAL constraint doesn't really map onto any specific kind of windowing. You can use whichever AFTER MATCH strategy meets your needs.