lead(value: storable, leadby: const int64) -> value

lead(value, leadby) returns value from the row found leadby rows later in the window partition order, where leadby is a non-negative compile-time integer constant. If no such following row exists within the frame the result is null. It requires window with grouping and ordering. For offset behavior that ignores null values in value, use lead_not_null.

Domain

This is a window function (calculates over a group of multiple input rows using windowing).

Categories

Examples

make_col nxt:window(lead(status, 1), group_by(host), order_by(valid_from))

Looks one row ahead in time order per host to surface the next status value on the current row.

make_col nxt2:window(lead(error_code, 2), group_by(trace_id), order_by(valid_from), frame(back:5m, ahead:5m))

Uses lead with offset two inside a symmetric frame to compare error codes later in the same trace.