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

PREV is parsed as LAST when the name of the pattern referenced is not the same with the pattern being defined

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Duplicate
    • 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 up_days,
          LAST(UP.tstamp) AS total_days
        PATTERN (STRT DOWN+ UP+)
        DEFINE
          DOWN AS DOWN.price < PREV(DOWN.price),
          UP AS UP.price > PREV(DOWN.price)
      ) AS T
      

      is parsed as

      ">(PREV(UP.$2, 0), LAST(DOWN.$2, 1))"
      

      I think this is not correct. PREV defines a physical offset, while LAST defines a logical offset.

      Attachments

        Issue Links

          Activity

            People

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

              Dates

                Created:
                Updated:
                Resolved: