cube icon indicating copy to clipboard operation
cube copied to clipboard

feat: Add query-time offset parameter for predefined granularities (implements #10042)

Open hank-sq opened this issue 5 months ago • 1 comments

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 avatar Oct 10 '25 18:10 hank-sq

@hank-sq Please see my comment here: https://github.com/cube-js/cube/issues/10042#issuecomment-3398996431

igorlukanin avatar Oct 13 '25 20:10 igorlukanin