How do I use time window functions?
When used with aggregating verbs, aggregate functions summarize many rows into one row.
Window functions are like aggregate functions, except they summarize previous and following rows into a scalar value, without changing the number of rows.
Any aggregate function can be turned into a window function by using make_col instead of the aggregate verb, and wrapping the aggregation in window().
Standard aggregation modifiers like group_by() and order_by() and frame() can be specified inside the window() which will make the function look at previous and successive rows to calculate the value.
Some special functions are only window functions, and cannot be used as aggregate functions. These include lead() and lag().
Example using window() for moving average:
Example using window() to find next event by container: