Expand description
Window Function FFI for JIT
External C functions for SQL-style window functions called from JIT-compiled code. Window functions require partition and ordering context, so these FFI functions operate on pre-computed partition data passed from the query executor.
Functionsยง
- jit_
window_ avg - AVG() over window frame Args: running_sum, count
- jit_
window_ count - COUNT() over window frame Args: count (pre-computed count over frame)
- jit_
window_ dense_ rank - DENSE_RANK() - Returns rank without gaps for ties Args: current_idx, partition_size Note: Simplified - assumes ORDER BY already applied and no ties
- jit_
window_ first_ value - FIRST_VALUE(expr) - Returns first value in the window frame
- jit_
window_ frame_ end - Calculate frame end index Args: current_idx, following (n following or -1 for unbounded), partition_size
- jit_
window_ frame_ start - Calculate frame start index Args: current_idx, preceding (n preceding or -1 for unbounded)
- jit_
window_ lag - LAG(value, offset) - Returns value from offset rows before current Args: current_value, offset, default_value, is_valid (1 if in bounds, 0 if out)
- jit_
window_ last_ value - LAST_VALUE(expr) - Returns last value in the window frame
- jit_
window_ lead - LEAD(value, offset) - Returns value from offset rows after current Args: current_value, offset, default_value, is_valid (1 if in bounds, 0 if out)
- jit_
window_ max - MAX() over window frame Args: running_max (pre-computed max over frame)
- jit_
window_ min - MIN() over window frame Args: running_min (pre-computed min over frame)
- jit_
window_ nth_ value - NTH_VALUE(expr, n) - Returns nth value in the window frame Args: nth_value, is_valid (1 if nth exists, 0 if not)
- jit_
window_ ntile - NTILE(n) - Distributes rows into n buckets Args: current_idx, partition_size, num_buckets
- jit_
window_ rank - RANK() - Returns rank with gaps for ties Args: current_idx, partition_size Note: Simplified - assumes ORDER BY already applied and no ties
- jit_
window_ row_ number - ROW_NUMBER() - Returns sequential row number within partition Args: current_idx (0-based position in partition)
- jit_
window_ sum - SUM() over window frame Args: running_sum (pre-computed sum over frame)