greedy_quantifiers.sql 742 B

123456789101112131415161718192021222324252627
  1. PRAGMA FeatureR010="prototype";
  2. PRAGMA config.flags("MatchRecognizeStream", "disable");
  3. $input = SELECT * FROM AS_TABLE([
  4. <|time: 0, name: 'A'|>,
  5. <|time: 100, name: 'B'|>,
  6. <|time: 200, name: 'C'|>,
  7. <|time: 300, name: 'B'|>,
  8. <|time: 400, name: 'C'|>,
  9. <|time: 500, name: 'A'|>,
  10. <|time: 600, name: 'B'|>,
  11. <|time: 700, name: 'C'|>,
  12. <|time: 800, name: 'W'|>,
  13. ]);
  14. SELECT * FROM $input MATCH_RECOGNIZE (
  15. ORDER BY CAST(time AS Timestamp)
  16. MEASURES
  17. FIRST(A.time) AS a_time,
  18. LAST(B_OR_C.time) AS bc_time,
  19. LAST(C.time) AS c_time
  20. PATTERN (A B_OR_C* C)
  21. DEFINE
  22. A AS A.name = 'A',
  23. B_OR_C AS (B_OR_C.name = 'B' OR B_OR_C.name = 'C'),
  24. C AS C.name = 'C'
  25. );