Expand description
SQLR-3 aggregate runtime.
Three concerns live here:
AggState— per-group accumulator state for COUNT/SUM/AVG/MIN/MAX, with SQLite-style numeric type rules (Sum stays Integer until a Real input or i64 overflow forces a one-time promotion to f64).DistinctKey— a hashable typed wrapper aroundValue, used both as the per-row key for GROUP BY and as the dedupe key forCOUNT(DISTINCT col)andSELECT DISTINCT.like_match— the iterative two-pointer LIKE matcher (case insensitive ASCII to match SQLite’s default).
All of this is pure-functional in the sense that nothing here touches
the Database/Table. The executor walks rows and feeds values in.
Enums§
- AggState
- Per-aggregate accumulator. One instance per (group, projection-slot) pair lives for the duration of the SELECT.
- Distinct
Key - A hashable typed wrapper around
Value, used as the GROUP BY key element and as theCOUNT(DISTINCT col)set entry. We can’timpl Hash for Valuebecause Value has aReal(f64)variant andf64isn’tHash + Eq. Round-trip viaf64::to_bitsto keep the canonical bit-pattern as the key — NaN keys remain distinguishable by exact bit pattern, which is the safer choice for grouping (we don’t try to be cute about NaN==NaN). - SumAcc
- SQLite-style numeric accumulator: stays
Intwhile every input is Integer and the running total fits in i64, otherwise promotes once toRealand never demotes back.
Functions§
- like_
match - SQL
LIKEmatcher.