MCPcopy Create free account
hub / github.com/NodeDB-Lab/nodedb / cume_dist_with_peers

Function cume_dist_with_peers

nodedb-query/src/window/eval.rs:215–236  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

213
214 #[test]
215 fn cume_dist_with_peers() {
216 let mut rows = vec![
217 ("a".into(), json!({"n": 1})),
218 ("b".into(), json!({"n": 1})),
219 ("c".into(), json!({"n": 2})),
220 ("d".into(), json!({"n": 3})),
221 ];
222 let spec = WindowFuncSpec {
223 alias: "cd".into(),
224 func_name: "cume_dist".into(),
225 args: vec![],
226 partition_by: vec![],
227 order_by: vec![(SqlExpr::Column("n".into()), true)],
228 frame: WindowFrame::default(),
229 };
230 evaluate_window_functions(&mut rows, &[spec]);
231 // Peers share value of last peer's position / N.
232 assert_eq!(rows[0].1["cd"], json!(0.5));
233 assert_eq!(rows[1].1["cd"], json!(0.5));
234 assert_eq!(rows[2].1["cd"], json!(0.75));
235 assert_eq!(rows[3].1["cd"], json!(1.0));
236 }
237
238 #[test]
239 fn nth_value_returns_nth_then_holds() {

Callers

nothing calls this directly

Calls 1

Tested by

no test coverage detected