Tested against: origin/main @ 09b8d9de (post-v0.3.0 main head, 2026-07-05)
Severity: High — standard SQL GROUP BY silently returns mis-keyed or empty aggregate data; consumers reading result columns by requested alias get wrong results with no error.
Summary
On a GROUP BY query the result shape diverges from the SELECT list three ways: (1) a plain-column select item's AS alias is ignored — the result column carries the base column name (aggregate aliases are honoured); (2) result columns come back group-keys-first regardless of SELECT-list order; (3) an unaliased aggregate returns empty cells. Non-grouped queries honour aliases and order correctly. Regression: worked before the response-shaping/output-schema rework.
Repro
CREATE COLLECTION grp (id TEXT PRIMARY KEY, label TEXT, score FLOAT) WITH (engine='document_strict');
INSERT INTO grp (id,label,score) VALUES ('r1','alpha',7);
INSERT INTO grp (id,label,score) VALUES ('r2','beta',3);
SELECT SUM(score) AS sum_score, label AS lbl FROM grp GROUP BY label;
-- columns: label | sum_score -- expected: sum_score | lbl ('lbl' dropped, order swapped)
SELECT label, SUM(score) FROM grp GROUP BY label;
-- label | sum(score)
-- alpha | -- empty cell, expected 7.0
-- beta | -- empty cell, expected 3.0
SELECT label AS lbl, score AS s FROM grp WHERE id = 'r1';
-- lbl | s -- control: aliases respected without GROUP BY
Expected
- Result columns carry the SELECT list's aliases, in SELECT-list order.
- Unaliased aggregates serialize their computed values.
Files (best-guess)
nodedb/src/control/server/response_shape/{schema,compose}.rs — group keys re-derived from the plan's grouping keys instead of the resolved projection
- planner output-schema builder, Aggregate variant — unaliased aggregate output column carries no value slot
Operational context
Any ORM or BI consumer that aliases its aggregates and group keys (the standard pattern) reads NULL group keys or empty aggregates — silently wrong analytics.
Tested against:
origin/main @ 09b8d9de(post-v0.3.0 main head, 2026-07-05)Severity: High — standard SQL GROUP BY silently returns mis-keyed or empty aggregate data; consumers reading result columns by requested alias get wrong results with no error.
Summary
On a GROUP BY query the result shape diverges from the SELECT list three ways: (1) a plain-column select item's
ASalias is ignored — the result column carries the base column name (aggregate aliases are honoured); (2) result columns come back group-keys-first regardless of SELECT-list order; (3) an unaliased aggregate returns empty cells. Non-grouped queries honour aliases and order correctly. Regression: worked before the response-shaping/output-schema rework.Repro
Expected
Files (best-guess)
nodedb/src/control/server/response_shape/{schema,compose}.rs— group keys re-derived from the plan's grouping keys instead of the resolved projectionOperational context
Any ORM or BI consumer that aliases its aggregates and group keys (the standard pattern) reads NULL group keys or empty aggregates — silently wrong analytics.