This phase added advanced statistical aggregation functions to the Go target, supporting both simple and grouped aggregation modes.
stddev(Field, Result): Sample Standard Deviation.- Implemented using Welford's Online Algorithm for single-pass efficiency and numerical stability.
- O(1) memory per group.
median(Field, Result): Median value.- Implemented with value collection and
sort.Float64s. - O(n) memory per group (required for median).
- Implemented with value collection and
percentile(Field, P, Result): P-th Percentile.- Supports arbitrary percentiles (e.g., 90th, 95th, 99th).
- Uses linear interpolation between closest ranks.
- Simple Aggregations: Works with
aggregate(Op, Goal, Result). - Grouped Aggregations: Works with
group_by(Group, Goal, Op, Result)and multi-aggregation lists. - HAVING Clause: Fully supported in post-aggregation filtering (e.g.,
group_by(...), StdDev > 5.0). - Target Support: Currently implemented for Go (Bbolt and JSONL modes).
- Conditional Imports: Only imports
mathorsortif the operations require them. - Helper Injection: Automatically injects necessary Go helper functions for median and percentile calculations.
tests/test_go_stats.pl: Verifiedstddev,median, andpercentilein both simple and grouped modes, including HAVING clause integration.