v1.2.0
🚀 GoSQLX v1.2.0 - Phase 2: Advanced SQL Features
📋 Major Release Overview
This release delivers Phase 2 of the GoSQLX roadmap, implementing comprehensive Common Table Expressions (CTE) and Set Operations support. GoSQLX now provides enterprise-grade SQL parsing with ~70% SQL-92 compliance while maintaining the high-performance, race-free architecture.
✨ Key Features Implemented
🔄 Common Table Expressions (CTEs)
- ✅ Simple CTEs:
WITH table_name AS (SELECT ...) - ✅ Recursive CTEs:
WITH RECURSIVE table_name AS (...) - ✅ Multiple CTEs: Support for comma-separated CTE definitions
- ✅ Column Specifications:
WITH cte(col1, col2) AS (...) - ✅ CTE Integration: Full compatibility with all statement types
🔗 Set Operations
- ✅ UNION: Standard set union with automatic deduplication
- ✅ UNION ALL: Set union preserving duplicates
- ✅ EXCEPT: Set difference (SQL standard, equivalent to MINUS)
- ✅ INTERSECT: Set intersection
- ✅ Left-Associative Parsing:
A UNION B INTERSECT C=(A UNION B) INTERSECT C - ✅ Combined Operations: CTEs with set operations in the same query
📊 Performance Metrics
| Metric | Value | Status |
|---|---|---|
| Sustained Throughput | 946K+ ops/sec (30s) | ✅ No Regression |
| Peak Throughput | 1.25M+ ops/sec (concurrent) | ✅ Enhanced |
| Token Processing | 8M+ tokens/sec | ✅ Maintained |
| Simple Query Latency | <280ns | ✅ Optimized |
| Complex Query Latency | <1μs (CTE/Set Ops) | ✅ New Capability |
| Memory Efficiency | 60-80% reduction | ✅ Preserved |
| Race Conditions | 0 detected | ✅ Thread-Safe |
🏗️ Technical Implementation
New Parser Functions
parseWithStatement()- Complete WITH clause parsing with recursive supportparseSelectWithSetOperations()- Set operations parsing with proper precedenceparseCommonTableExpr()- Individual CTE parsing with column specificationsparseMainStatementAfterWith()- Post-CTE statement routing
Enhanced Test Coverage
pkg/sql/parser/cte_test.go- 4 comprehensive CTE test functionspkg/sql/parser/set_operations_test.go- 5 comprehensive set operation tests- Coverage: Simple CTE, Recursive CTE, Multiple CTEs, Set Operations, Complex Combinations
🎯 SQL Standards Compliance
✅ SQL-92 Features Implemented
- Common Table Expressions (WITH clause)
- Recursive queries (WITH RECURSIVE)
- Set operations (UNION, EXCEPT, INTERSECT)
- Complex query compositions
- Proper operator precedence
📈 Compliance Progress
- Phase 1: ~40% SQL-92 compliance (Basic SELECT, JOINs)
- Phase 2: ~70% SQL-92 compliance (CTEs, Set Operations) ⬅️ Current
- Phase 3 Target: 90%+ compliance (Window Functions, Advanced Features)
🔧 Production Deployment
✅ Ready for Production
- Enterprise Workloads: Handles complex SQL parsing at scale
- High-Throughput Systems: 946K+ operations/second sustained
- Mission-Critical Applications: Race-free, memory-safe operation
- International Usage: Full Unicode SQL support maintained
🚀 Deployment Requirements
- Go Version: Go 1.19+ (tested with Go 1.21+)
- Memory: Object pools auto-scale, minimal configuration needed
- Concurrency: Scales linearly, no artificial limits
- Monitoring: Built-in metrics and memory leak detection
📋 Example Usage
Simple CTE
WITH sales_summary AS (
SELECT region, SUM(amount) as total
FROM sales GROUP BY region
)
SELECT region FROM sales_summary WHERE total > 1000Recursive CTE
WITH RECURSIVE employee_tree AS (
SELECT employee_id, manager_id, name FROM employees WHERE manager_id IS NULL
UNION ALL
SELECT e.employee_id, e.manager_id, e.name
FROM employees e JOIN employee_tree et ON e.manager_id = et.employee_id
)
SELECT * FROM employee_treeSet Operations
SELECT name FROM users UNION SELECT name FROM customers;
SELECT id FROM orders UNION ALL SELECT id FROM invoices;
SELECT product FROM inventory EXCEPT SELECT product FROM discontinued;
SELECT customer_id FROM orders INTERSECT SELECT customer_id FROM payments;Combined CTE + Set Operations
WITH regional AS (SELECT region FROM sales)
SELECT region FROM regional UNION SELECT region FROM returns;🔄 Backward Compatibility
- ✅ 100% Backward Compatible: All existing functionality preserved
- ✅ API Stability: No breaking changes to public interfaces
- ✅ Legacy Tests: All Phase 1 and prior tests continue passing
- ✅ Performance: No degradation in existing query parsing
🔜 Next Steps (Phase 3 - Q1 2025)
Phase 2 lays the groundwork for Phase 3 advanced features:
- Window Functions: OVER clauses, ranking functions
- Advanced JOINs: LATERAL joins, multiple-column USING clauses
- Subquery Enhancements: Correlated subqueries, EXISTS clauses
- Data Modification: Enhanced INSERT/UPDATE/DELETE with CTEs
- SQL-99 Compliance: Advanced analytical functions
📝 Full Changelog
Added
- Complete Common Table Expression (CTE) parsing with recursive support
- Set operations: UNION, UNION ALL, EXCEPT, INTERSECT with proper precedence
- Multiple CTE definitions in single query
- CTE column specifications
- Integration of CTEs with set operations
- Comprehensive test coverage for all new features
- Enhanced Go package documentation with Phase 2 examples
Changed
- Enhanced parser statement routing to support set operations
- Improved WITH clause attachment for complex statement types
- Updated performance metrics and benchmarks
Performance
- Maintains 946K+ sustained operations per second
- Zero performance regression from Phase 1
- Memory-efficient object pooling preserved
- Race-free concurrent access validated
🎉 GoSQLX v1.2.0 delivers enterprise-grade SQL parsing with advanced CTE and set operations support!