For table Ticker:
symbol: string tstamp: long price: int
, the UP in the following sql
SELECT * FROM Ticker MATCH_RECOGNIZE ( MEASURES STRT.tstamp AS start_tstamp, LAST(DOWN.tstamp) AS bottom_tstamp, LAST(UP.tstamp) AS end_tstamp ONE ROW PER MATCH PATTERN (STRT DOWN+ UP+) DEFINE DOWN AS DOWN.price < PREV(DOWN.price), UP AS UP.price > PREV(LAST(DOWN.price, 1), 1) ) AS T
is parsed as follows:
">(PREV(UP.$2, 0), LAST(DOWN.$2, 1))"
I think this is not as expected. According to the documentation about MATCH_RECOGNIZE, it supports nesting LAST/FIRST within PREV/NEXT and we should not just ignore the PREV.
- is duplicated by
CALCITE-1872 PREV is parsed as LAST when the name of the pattern referenced is not the same with the pattern being defined