fix(exec): Emit TopNRowNumber in-memory partitions in ascending rank order (#18529)
Sole Author: Patrick Ribbsaeter (@patrickswedish) · Immutable Commit SHA: 8612db55bbc545a0b8bc0d7549591b75dc509a0e
Vectorized C++20 execution engine fix reordering retained in-memory max-heap partition rows into ascending rank sequence before vector batch emission, unifying in-memory and spilled WindowNode semantics.

PR #18529
Merged Mainline
8612db5
Immutable Git SHA
C++20
Systems
38/38 CI Green
CI & Test Matrix
01 · Engineering problem
The failure mode
TopNRowNumber's in-memory max-heap was drained directly into output, emitting retained rows in descending rank order within each partition while WindowNode and the spilled execution path emitted ascending per-partition rank order.
02 · Technical response
What changed
- 01Reversed retained in-memory partition heap output to emit ascending per-partition rank order.
- 02Aligned row_number, rank, and dense_rank state progression for forward partition output.
- 03Added exact-order regression tests comparing TopNRowNumber against WindowNode across in-memory and spilled runs.
03 · Verified outcome
Evidence-backed result
- ✓In-memory TopNRowNumber emits rows in ascending rank order within each partition, matching spilled execution and WindowNode.
- ✓Merged upstream into facebookincubator/velox main branch as commit 8612db55bbc545a0b8bc0d7549591b75dc509a0e.
04 · Cryptographic Git record
Immutable source evidence
Independent open-source engineering authored solely by Patrick Ribbsaeter (@patrickswedish). Company and project names identify the public repository context only under nominative fair use. No employment, client, vendor, or partnership relationship is implied unless explicitly stated.