Uploaded image for project: 'Flink'
  1. Flink
  2. FLINK-19755

Fix CEP documentation error of the example in 'After Match Strategy' section

    XMLWordPrintableJSON

    Details

      Description

       symbol   tax   price         rowtime
      ======== ===== ======= =====================
       XYZ      1     7       2018-09-17 10:00:01
       XYZ      2     9       2018-09-17 10:00:02
       XYZ      1     10      2018-09-17 10:00:03
       XYZ      2     5       2018-09-17 10:00:04
       XYZ      2     17      2018-09-17 10:00:05
       XYZ      2     14      2018-09-17 10:00:06
      
      
      SELECT *
      FROM Ticker
          MATCH_RECOGNIZE(
              PARTITION BY symbol
              ORDER BY rowtime
              MEASURES
                  SUM(A.price) AS sumPrice,
                  FIRST(rowtime) AS startTime,
                  LAST(rowtime) AS endTime
              ONE ROW PER MATCH
              [AFTER MATCH STRATEGY]
              PATTERN (A+ C)
              DEFINE
                  A AS SUM(A.price) < 30
          )
       
      
      
      AFTER MATCH SKIP TO LAST A 
      
      symbol   sumPrice        startTime              endTime
      ======== ========== ===================== =====================
       XYZ      26         2018-09-17 10:00:01   2018-09-17 10:00:04
       XYZ      15         2018-09-17 10:00:03   2018-09-17 10:00:05
       XYZ      22         2018-09-17 10:00:04   2018-09-17 10:00:06
       XYZ      17         2018-09-17 10:00:05   2018-09-17 10:00:06
      
      Again, the first result matched against the rows #1, #2, #3, #4.Compared to the previous strategy, the next match includes only row #3 (mapped to A) again for the next matching.
      
      Therefore, the second result matched against the rows #3, #4, #5.
      
      The third result matched against the rows #4, #5, #6.
      
      The last result matched against the rows #5, #6.
      i think it will exist looping match when coming to 17, 14 using "AFTER MATCH SKIP TO LAST A "

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                jackylau jackylau
                Reporter:
                jackylau jackylau
              • Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: