Turn event order into a result
Execution sketchA followed by one or more B events
DEFINE AA
DEFINE BB #1
DEFINE BB #2
MEASURESMatch
Increasing sequenceChronusQL
SELECT mr.run_id, mr.start_price, mr.end_price
INTO output
FROM input TIMESTAMP BY ts
MATCH_RECOGNIZE (
PARTITION BY run_id
LIMIT Duration(second, 10)
MEASURES
A.run_id AS run_id,
A.price AS start_price,
LAST(B.price) AS end_price
ONE ROW PER MATCH
AFTER MATCH SKIP TO NEXT ROW
PATTERN (A B+)
DEFINE
A AS A.kind = 'A',
B AS B.kind = 'B' AND B.price > PREV(B.price)
) AS mrClause responsibilities
- 01PARTITION BY
Keeps pattern state independent for each key.
- 02LIMIT
Bounds the elapsed event time of a candidate match.
- 03MEASURES
Names values projected from a successful match.
- 04ONE ROW PER MATCH
Emits one result object for the match.
- 05AFTER MATCH SKIP TO NEXT ROW
Advances the next candidate start by one source row.
- 06PATTERN
Declares variable order, alternatives, and repetition.
- 07DEFINE
Declares the predicate for every named pattern variable.