Skip to content

feat(v2.6.0): aggregates with derived GROUP BY - #29

Merged
ikelaiah merged 2 commits into
mainfrom
feat/aggregates
Sep 20, 2026
Merged

ikelaiah merged 2 commits into
mainfrom
feat/aggregates

Conversation

@ikelaiah

Copy link
Copy Markdown
Owner

What

v2.6.0 feature work: aggregate functions with derived GROUP BY, plus the version-2 query file format.

1. feat(erd): aggregates with derived GROUP BY

  • Per-picked-column selector: COUNT, COUNT DISTINCT, SUM, AVG, MIN, MAX.
  • Non-aggregated picks become GROUP BY in pick order; omitted when every pick is aggregated; aggregate expressions get deterministic aliases (count_orderheader_orderid).
  • Sorting an aggregated column orders by the expression (ORDER BY COUNT(...) DESC).
  • DISTINCT is disabled and suppressed with a provenance note while grouping; a plan tip explains one-to-many multiplication.
  • Query files move to version 2: version-1 files migrate forward with empty aggregates; newer versions are rejected with a diagnostic. Aggregates are saved, exported, restored, and pruned with their picks.
  • Unknown aggregate functions are ignored, never guessed.

2. docs(erd): document aggregates and record ADR-003

  • ADR-003 records derived GROUP BY, the function set, DISTINCT suppression, aggregate ordering, and the v2 migration, with rejected alternatives (HAVING, explicit GROUP BY, COUNT(*), window functions).
  • docs/QUERY_BUILDER.md gains the aggregates section and the v2 file sample; USER_GUIDE and README mention the selector; ARCHITECTURE notes aggregate emission.

Verification

  • Golden 221/221 (query suite now 55 records: five aggregate engine records, v1 migration, plus storage/prune updates)
  • ERD UI suite 68/68 over HTTP (aggregate selector, function rendering, GROUP BY, DISTINCT suppression, tip, reset)
  • typecheck, build, test:file green locally; metrics, package:smoke, Firefox smoke run in CI
  • dist/ rebuilt and committed; no version bump yet — the release commit follows after merge

Engine:
- Per-picked-column aggregate functions (COUNT, COUNT DISTINCT, SUM, AVG,
  MIN, MAX). Non-aggregated picks become GROUP BY in pick order; GROUP BY is
  omitted when every pick is aggregated; ORDER BY can target the aggregate
  expression; DISTINCT is suppressed with a provenance note because GROUP BY
  already collapses rows. Unknown functions are ignored.
- Query files move to version 2; version-1 files migrate forward with empty
  aggregates, and newer versions are rejected.

Panel:
- Each picked-column chip gains an aggregate selector; DISTINCT disables
  while grouping; a plan tip explains one-to-many multiplication; aggregates
  are pruned with their picks, saved, exported, and restored.

Tests: five aggregate engine records, version-1 migration, storage/prune
updates, and six ERD UI checks (68 total).
- ADR-003 records derived GROUP BY, the six functions, the DISTINCT
  suppression, aggregate ordering, and the version-2 migration, with the
  rejected alternatives (HAVING, explicit GROUP BY, COUNT(*), window
  functions).
- QUERY_BUILDER.md gains the aggregates section, the v2 file sample, and the
  updated non-goals; USER_GUIDE and README mention the selector; ARCHITECTURE
  notes aggregate emission.
@ikelaiah
ikelaiah merged commit 777080b into main Sep 20, 2026
4 checks passed
@ikelaiah
ikelaiah deleted the feat/aggregates branch September 20, 2026 22:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant