pub fn rank_int<T: Ord + Copy>(window: IntegerAVT<'_, T>) -> IntegerArray<i32>Expand description
Computes standard SQL ROW_NUMBER() ranking for integer data with tie handling.
Assigns sequential rank values to elements based on their sorted order, providing standard SQL ROW_NUMBER() semantics where tied values receive different ranks. Essential for analytical queries requiring unique positional ranking.
§Parameters
window- Integer array view containing values for ranking
§Returns
Returns an IntegerArray<i32> containing:
- Rank values from 1 to n for valid elements
- Zero values for null elements
- Null mask indicating which positions have valid ranks
§Ranking Semantics
- ROW_NUMBER() behaviour: Each element receives a unique rank (1, 2, 3, …)
- Tie breaking: Tied values receive different ranks based on their position
- Ascending order: Smaller values receive lower (better) ranks
- Null exclusion: Null values are excluded from ranking and receive rank 0
§Use Cases
- Analytical queries: SQL ROW_NUMBER() window function implementation
- Leaderboards: Creating ordered rankings with unique positions
- Percentile calculation: Basis for percentile and quartile computations
- Data analysis: Establishing ordinality in integer datasets
§Examples
ⓘ
use minarrow::IntegerArray;
use simd_kernels::kernels::window::rank_int;
let arr = IntegerArray::<i32>::from_slice(&[30, 10, 20, 10]);
let result = rank_int((&arr, 0, arr.len()));
// Output: [4, 1, 3, 2] - ROW_NUMBER() style ranking