permute.sql 761 B

1234567891011121314151617181920212223242526272829303132333435
  1. $data = [
  2. <|dt:1688910000, event:"A"|>,
  3. <|dt:1688910100, event:"B"|>,
  4. <|dt:1688910200, event:"C"|>,
  5. <|dt:1688910300, event:"A"|>,
  6. <|dt:1688910400, event:"C"|>,
  7. <|dt:1688910500, event:"D"|>,
  8. <|dt:1688910500, event:"C"|>,
  9. <|dt:1688910600, event:"B"|>,
  10. <|dt:1688910800, event:"A"|>,
  11. <|dt:1688910900, event:"C"|>,
  12. <|dt:1688911000, event:"B"|>,
  13. ];
  14. pragma FeatureR010="prototype";
  15. SELECT *
  16. FROM AS_TABLE($data) MATCH_RECOGNIZE(
  17. ORDER BY CAST(dt as Timestamp)
  18. MEASURES
  19. FIRST(A.dt) as a,
  20. FIRST(B.dt) as b,
  21. FIRST(C.dt) as c
  22. ONE ROW PER MATCH
  23. AFTER MATCH SKIP TO NEXT ROW
  24. PATTERN (
  25. PERMUTE(A, B, C)
  26. )
  27. DEFINE
  28. A as A.event = "A",
  29. B as B.event = "B",
  30. C as C.event = "C"
  31. ) AS MATCHED
  32. ;