Uploaded image for project: 'Calcite'
  1. Calcite
  2. CALCITE-1871

Nesting LAST within PREV is not parsed correctly for MATCH_RECOGNIZE

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • 1.14.0
    • None

    Description

      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.

      Attachments

        Issue Links

          Activity

            People

              ransom Zhiqiang He
              dian.fu Dian Fu
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: