row_number

Aliases: rownumber (deprecated).

row_number() -> int64

row_number() returns a unique int64 index from 1 up within each window partition in deterministic order given the window ordering, with no special tie handling beyond whatever the ordering specifies. It accepts no arguments and only works inside window or another context that supplies grouping, ordering, and optionally frame. Two rows can share a rank with rank or dense_rank but never share a row_number unless the ordering is truly ambiguous.

Domain

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

Categories

Examples

make_col rn:window(row_number(), group_by(host), order_by(valid_from))

Numbers observations 1, 2, 3 in time order separately for each host using row_number.