I am using match recognize query to my stream and order by (event_time) where event_time field is of type timestamp. I have added assignTimestampsAndWatermarks() to the field in stream and then create table followed by the query but i get the error rowtime or proctime should be first in order by. Here is my code snippet:
mapTimestampStream = mapStream.assignTimestampsAndWatermarks(new AscendingTimestampExtractor<Tuple10<String, String, String, String, String, String, Timestamp, String, String, Timestamp>>() {
private static final long serialVersionUID = 1L;
@Override
public long extractAscendingTimestamp(Tuple10<String, String, String, String, String, String, Timestamp, String, String, Timestamp> element) {
long timestamp = Timestamp.valueOf(element.getField(6).toString()).getTime();
return timestamp;
}
});
Table state_Table = bsTableEnv.fromDataStream(mapTimestampStream, XAASUtil.EB_JOURNEY_STATE_TABLE_SCHEMA);
bsTableEnv.registerTable("eb_user_journey", state_Table);
Table matchResult = bsTableEnv.sqlQuery(
"Select Id, StartTime, EndTime from eb_user_journey MATCH_RECOGNIZE( PARTITION BY user_id ORDER BY event_time MEASURES A.user_id AS Id, FIRST(A.event_time) AS StartTime, LAST(A.event_time) AS EndTime"
+ " AFTER MATCH SKIP TO NEXT ROW " + " PATTERN (A+ B) "
+ " DEFINE A as A.user_id = 1001 )");