1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
//! Scan iterator contract for [`super::AggregateQueryPlanner`].
//!
//! The dispatcher wraps the production entity scan in a
//! [`ScanIterator`] that yields per-row values *without* building a
//! full `UnifiedRecord` — that's the entire point of the push-down.
//!
//! Tests live in `tests.rs` and use a trivial `Vec<ScanRow>` adapter
//! to exercise the planner deterministically.
use crateValue;
/// One row delivered by [`ScanIterator::next_row`].
///
/// `group_key` is the value of the single GROUP BY column for this
/// row (typed — `Value::Null` is a legal grouping key, matching SQL
/// "everything-NULL" group semantics).
///
/// `agg_inputs` is positional: aggregate at AST index `i` reads
/// `agg_inputs[i]`. The `CountStar` aggregate ignores its slot.
/// One emitted row from the planner: GROUP BY value plus the
/// finalised aggregate per AST position.
///
/// The dispatcher converts this into the surrounding `UnifiedRecord`
/// shape — keeping the planner's output type narrow means the unit
/// tests don't have to deal with the wider record machinery.
/// Producer side of the push-down.
///
/// A single `next_row()` call returns the next row or `None` at
/// end-of-stream. Errors propagate through the planner's `Result`
/// return — the trait itself is fail-fast (returning `None`).
///
/// Implementors are free to stream, prefetch, or block — the
/// planner only consumes one row at a time and never re-reads.
/// Result type emitted by [`super::AggregateQueryPlanner::plan`].
///
/// Materialised eagerly today — the per-group state is finalised
/// after the scan completes, so streaming would require either a
/// sorted scan (follow-up) or splitting accumulation from emission
/// (also follow-up). Both are explicit non-goals in this slice.