cube
cube copied to clipboard
feat: Add query-time offset parameter for predefined granularities (implements #10042)
Check List
- [X] Tests have been run in packages where changes have been made if available
- [ ] Linter has been run for changed code
- [X] Tests for the changes have been added if not covered yet
- [ ] Docs have been added / updated if required
Issue Reference this PR resolves
#10042
Description of Changes Made (if issue reference is not provided)
Adds support for a query-time offset parameter on timeDimensions that allows shifting time boundaries for predefined granularities (day, week, month, etc.). This enables use cases like:
- Days running 2am-2am instead of midnight-midnight
- Weeks starting on Wednesday instead of Monday
The offset parameter:
- Only works with predefined granularities (day, week, month, etc.)
- Throws a validation error if used with custom granularities
- Uses SQL interval syntax (e.g., "2 hours", "-30 minutes", "2 days")
- Is supported in REST API and GraphQL API
Includes comprehensive unit and integration tests demonstrating the day-shifting and week-shifting use cases.
@hank-sq Please see my comment here: https://github.com/cube-js/cube/issues/10042#issuecomment-3398996431