Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

name: op-win-rank
description: Sparse rank with gaps after ties (1, 2, 2, 4, ...) within the ordered partition.
kind: operator
category: WIN
operator: WIN_RANK
type: reference
applies_to: process, compose, predict
examples_tags: [cohort-analysis, top-n, window-operator, buffered-pipeline]

Window operators emit row-level values; they do not produce Response.Components.

Use when

Ranks rows within each partition in the chosen order; rows with equal values share a rank and the next skips: 1, 2, 2, 4.

Questions it answers:

  • Where does each store rank on revenue within its region?
  • Which product came first in each month by units sold?

Use something else:

  • WIN_DENSE_RANK when equal values should share a rank with no gap after them.

Params

None. partition_by (carve), order_by (≥1, required, any type but set_* (PULSE_WINDOW_INVALID) or vec_* (PULSE_VECTOR_FIELD_NOT_SCALAR) — tie comparison reads these keys), frame (forbidden), field (refused PULSE_WINDOW_INVALID — no value read; manifest forbids_field, accepts_types: []).

Inputs

  • field — must be empty / omitted — WIN_RANK reads ranking from order_by keys only

Output

One integer per row written to label (default WIN_RANK). Ties (rows equal on every order_by key) share a rank; next distinct row advances by the tie count — (1, 2, 2, 4, 5). Rank resets per partition.

Reading the output

  • value: The row’s position in order_by order within its partition, starting at 1. Rows equal on every order_by key share a rank, and the next rank skips past them: 1, 2, 2, 4. A row’s rank is 1 plus the number of rows strictly before it.
    • Caveat: Rank 1 is the first row in order_by order: the smallest value with an ascending key, the largest with desc. Say which when reporting a ‘top’ rank.
    • Caveat: Rows tie only when equal on every order_by key; rows with a missing order_by value sort last and tie with each other, so they share the last rank.

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

  • order_by defines BOTH scan order AND tie key — same field choice changes the answer.
  • Multiple order_by keys: tie only when ALL keys equal.
  • Result rows are NOT reordered — use sort for response order.

See