Repository navigation
Description
Release requirement
The maintainer requires consistent handling of nonnumeric argument values between ordinary and window aggregates before v3.0.0 ships: update the ordinary forms to match the window forms. This follows the #777 design discussion on 2026-10-29.
#777 implements ordinary avg only: it will skip nil and all nonnumeric values, counting only numbers, as window avg already does. This issue tracks the other aggregates. No v2 runtime backport.
Current discrepancies on v3
Source reviewed at 5f8073250 in src/query/datalog/aggregate.rs (Agg::step/finish versus Running::step/value and bounded-frame evaluation):
| Function | Ordinary | Window |
|---|---|---|
sum |
Non-nil nonnumbers fail with INT-041 | Skips nonnumbers |
min / max |
Only homogeneous Integer, Float, or String values; mixed types fail with INT-043 and unsupported types with INT-044 | Skips nil; compares all other values with the existing total order |
count |
Counts every non-nil value | Same |
For example, over values 10, "unknown", 20, ordinary sum errors while the final cumulative window sum is 30. Window min/max also handle keywords, booleans, refs, sets and mixed integers/floats that ordinary min/max reject.
Skipping an aggregate argument does not remove its source row: it still occupies a bounded-window position and receives a window result.
Requested work
- Make ordinary
sumskip nonnumeric values, matching windowsum. - Make ordinary
min/maxuse the same supported value domain and total ordering as their window forms, including mixed numeric types and nonnumeric values. - Audit
count,count-distinct, andsum-distinctfor consistent argument handling. Preserve distinctness; there are no built-in window forms of the distinct variants. In particular, alignsum-distinct's numeric filtering with the chosen sum contract. - Explicitly settle and test all-nil/all-nonnumeric existing groups versus no matching rows. Preserve grouping,
:with, multiplicity, and the structural distinction between ordinary and window results; do not silently change empty-query conventions. - Test every Value variant, mixed-type inputs, signed zeros, NaNs/infinities, permutations, grouped/ungrouped queries, prepared queries, cursors, rule queries, bounded/default windows and plan independence. Compare an ordinary aggregate with the corresponding window over the same argument population.
- Review aggregate error precedence and documented INT-041/042/043/044 behavior after removing type restrictions.
- Coordinate with perf(query): extend ordered Aggregate beyond one-key count groups #781: changes to fallibility affect ordered-Aggregate eligibility, but require its separate pipeline/order proofs.
- Synchronize current repository docs and version-scoped docs-site references, preserving v2 behavior.
Boundaries
Target v3.0.0; this is a release requirement, not v3.next. No new dependencies, configuration or storage/WAL changes. Preserve window behavior and update the ordinary forms. #777 owns avg; avoid overlapping its implementation. Obtain spec/plan and final code reviews and use the bench machine for heavy verification.
Activity
Merge pull request #792 from project-minigraf/feat/789-aggregate-values