Analytics Engineering, Bigquery, Sql, Data Engineering, Editors Pick.
by author. So, what does the code look like? Let’s focus only on promotions for a while. The first step is to retrieve the “start_datetime” of the next event; this will help us detect when there is a discontinuity: SELECT ... ARRAY( SELECT AS STRUCT *, LAG(start_datetime) OVER (ORDER BY