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

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Duplicate
    • Affects Version/s: None
    • Fix Version/s: 1.14.0
    • Component/s: None
    • Labels:

      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

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

                Dates

                • Created:
                  Updated:
                  Resolved: