Rows with the same key share a bucket.

highlighted = computed this step

Make group buckets

Rows with the same group key go into the same bucket.

same key, same bucket\text{same key, same bucket}

Show the buckets

The compiler forms 3 buckets and lists their source rows.

groups=3\text{groups}=3

Grouping examples are tiny finite table transforms; SQL dialects, NULLs, AVG/rounding, planner behavior, indexes, performance, and product behavior are out of scope.

Make group buckets: base rowssourceRowidkindqty01book212game123book334game445tool1 group by columnscolumnkind aggregate specsopcolumnascount_rowsrowsn group bucketskeysourceRowsrowCount[book][0, 2]2[game][1, 3]2[tool][4]1 aggregate rowskeyn[book]2[game]2[tool]1 having keep/dropkeystatusreason[book]keepno_having[game]keepno_having[tool]keepno_having output rowskeyn[book]2[game]2[tool]1 group factsfactvaluerowCount5groupByColumnCount1groupCount3aggregateCount1outputGroupCount3havingnonehiddenGroupsno

Read the key order

Group keys are sorted with a deterministic canonical key, so the buckets render in a stable order.

canonical group order\text{canonical group order}

Summary

A bucket is just a visible set of source rows sharing a key.

bucket = source rows\text{bucket = source rows}