pub enum WindowFn {
Show 14 variants
RowNumber,
Rank {
order_column: Option<String>,
},
DenseRank {
order_column: Option<String>,
},
Lead {
offset: usize,
default: f64,
},
Lag {
offset: usize,
default: f64,
},
Delta,
Rate,
IRate,
MovingAverage {
window_size: usize,
},
CumulativeSum,
Increase,
RangeMovingAverage {
range_ns: i64,
},
RangeSum {
range_ns: i64,
},
RangeCount {
range_ns: i64,
},
}Expand description
Window function type.
Variants§
RowNumber
Sequential 1-based row number within partition.
Rank
Rank with gaps for ties on the order column.
When order_column is Some, rank is determined by that
column (SQL standard RANK() OVER (ORDER BY ...)). When None,
defaults to the value column for backward compatibility.
DenseRank
Rank without gaps for ties on the order column.
Same order_column semantics as Rank.
Lead
Value offset rows ahead; default if out of range.
Fields
Lag
Value offset rows behind; default if out of range.
Fields
Delta
Difference: value[i] - value[i-1] (null for first row).
Rate
Per-second rate: (value[i] - value[i-1]) / (timestamp[i] - timestamp[i-1]).
§Timestamp unit assumption
Timestamps are assumed to be nanoseconds since the Unix epoch
(the standard unit throughout Chronix). The delta is divided by
1_000_000_000.0 to convert to seconds before computing the rate.
If timestamps use a different unit (e.g. microseconds or millis),
the rate values will be incorrect by the corresponding scale factor.
IRate
Instantaneous per-second rate between the last two samples in the partition. Every row in the partition gets the same value.
Uses the same nanosecond timestamp assumption as Rate.
MovingAverage
Simple moving average over a sliding window of window_size rows.
CumulativeSum
Running cumulative sum.
Increase
Monotonic counter increase (resets to 0 on counter wrap-around).
RangeMovingAverage
RANGE-frame moving average over a timestamp window.
For each row, computes the mean of all values whose timestamps fall
within [current_ts - range_ns, current_ts]. Uses an efficient
two-pointer O(n) scan (data is sorted by timestamp).
RangeSum
RANGE-frame sum over a timestamp window.
RangeCount
RANGE-frame count over a timestamp window.