(
rows: &mut [(String, serde_json::Value)],
indices: &[usize],
spec: &WindowFuncSpec,
)
| 57 | } |
| 58 | |
| 59 | pub(super) fn apply_lead( |
| 60 | rows: &mut [(String, serde_json::Value)], |
| 61 | indices: &[usize], |
| 62 | spec: &WindowFuncSpec, |
| 63 | ) { |
| 64 | let field = col_arg(spec, 0); |
| 65 | let offset = usize_arg(spec, 1, 1); |
| 66 | let default = default_arg(spec, 2); |
| 67 | |
| 68 | for (pos, &i) in indices.iter().enumerate() { |
| 69 | let val = if pos + offset < indices.len() { |
| 70 | get_field(&rows[indices[pos + offset]].1, field) |
| 71 | } else { |
| 72 | default.clone() |
| 73 | }; |
| 74 | set_window_col(&mut rows[i].1, &spec.alias, val); |
| 75 | } |
| 76 | } |
| 77 | |
| 78 | /// PostgreSQL `nth_value(expr, n)` — value of `expr` at the n'th row of the |
| 79 | /// window frame, NULL if the frame doesn't yet contain n rows. Default frame |
no test coverage detected