name: op-win-row-number
description: 1-based row index within the ordered partition; never ties.
kind: operator
category: WIN
operator: WIN_ROW_NUMBER
type: reference
applies_to: process, compose, predict
examples_tags: [top-n, window-operator, buffered-pipeline]
Window operators emit row-level values; they do not produce Response.Components.
Use when
Numbers the rows 1, 2, 3 within each partition in the chosen order, for picking the first few rows of every group.
Questions it answers:
- Which are the top three products by revenue in each region?
- What is each customer’s first order, by date?
Use something else:
WIN_RANKwhen rows with equal values should share a position.WIN_DENSE_RANKwhen you want ranks without gaps after equal values.
Params
None. partition_by (carve), order_by (≥1, required, any type but set_* (PULSE_WINDOW_INVALID) or vec_* (PULSE_VECTOR_FIELD_NOT_SCALAR)), frame (forbidden), field (refused PULSE_WINDOW_INVALID — no value read; manifest forbids_field, accepts_types: []).
Inputs
field— must be empty / omitted — no value field is read
Output
One integer per row written to label (default WIN_ROW_NUMBER). Counts 1, 2, 3, ... in scan order, resets per partition. NEVER ties — row order is stable (nulls last) on the order_by comparator.
Contract
- Types: reads no field; naming one is
PULSE_WINDOW_INVALID. - Weight: no weighted form and no slot weight; a request weight is
PROCESSING_CONFIG, an instance default is skipped. - Streaming: buffered only.
Gotchas
- Ties on
order_by: ROW_NUMBER picks a deterministic but arbitrary order. - Common top-N idiom:
WIN_ROW_NUMBERpartitioned by group, then a range filter on the label[1, N]. Filters run BEFORE windows, and a chain stage refuses windows: write the label first withpulse_materialize(derived-cohorts), then filter the new cohort. - Result rows are NOT reordered — use
sortfor response order.
See
pulse_examples_search tags=[top-n]- Skills:
window-design,op-win-rank,op-win-dense-rank