You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat: implement GROUPING SETS, ROLLUP, CUBE support (SQL-99 T431)
Implement SQL-99 advanced grouping operations for aggregate queries:
## New Features
- ROLLUP(col1, col2, ...) - hierarchical subtotals (SQL-99 syntax)
- CUBE(col1, col2, ...) - all possible subtotal combinations (SQL-99 syntax)
- GROUPING SETS((a,b), (a), ()) - explicit grouping set specification
- GROUP BY cols WITH ROLLUP/CUBE - MySQL syntax support
## Implementation Details
### AST Nodes (ast.go)
- RollupExpression: stores column list for ROLLUP operation
- CubeExpression: stores column list for CUBE operation
- GroupingSetsExpression: stores list of grouping sets (including empty sets)
### Parser (parser.go)
- parseGroupingExpressionList(): shared helper for ROLLUP/CUBE parsing
- parseRollup(): parses ROLLUP(columns) with validation
- parseCube(): parses CUBE(columns) with validation
- parseGroupingSets(): parses GROUPING SETS with nested sets support
- Updated parseGroupByClause() to detect and route to correct parser
- Added MySQL syntax support: GROUP BY cols WITH ROLLUP/CUBE
### Tokenizer (tokenizer.go)
- Added ROLLUP, CUBE, GROUPING, SETS as keyword token types
- Added "GROUPING SETS" compound keyword support
### Keywords (keywords.go, categories.go)
- Registered keywords in ADDITIONAL_KEYWORDS
- Added to DMLKeywords and CompoundKeywords maps
## Validation
- Empty ROLLUP() returns error: "ROLLUP requires at least one expression"
- Empty CUBE() returns error: "CUBE requires at least one expression"
- Empty set in GROUPING SETS(()) is valid (SQL-99 compliant for grand total)
## Tests
- 7 formal test cases in parser_coverage_test.go
- Tests cover valid syntax, empty validation, and mixed operations
- All integration tests pass including MySQL WITH ROLLUP syntax
Closes#67 (Phase 1: GROUPING SETS, ROLLUP, CUBE)
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
0 commit comments