If you like simple approaches to pattern and sequence detection using #SQL, Databricks now supports MATCH_RECOGNIZE to look for patterns row over row.
https://www.databricks.com/blog/regex-rows-simplifying-pattern-detection-sql-matchrecognize
Simplifying Pattern Detection with MATCH_RECOGNIZE | Databricks Blog
Databricks solves complex sequence detection with MATCH_RECOGNIZE, bringing regex-style pattern matching to relational data, without self-joins or chained CTEs.