Skip to content

Query specified timeDimension granularity offset? #10042

@hank-sq

Description

@hank-sq

Problem

I'd like to be able to customize the 'offset' of timeDimension granularities at query time. For example, I want to support a client that maybe wants to group by a time dimension with daily granularity, but for that day to map to 2:30am -> 2:30am.

For example, if there's the following data with a created_at time at:

  • 2025-01-01T00:00:00Z
  • 2025-01-01T01:00:00Z
  • 2025-01-01T02:00:00Z
  • 2025-01-01T03:00:00Z

I want the ability to have the query timezone be UTC, group by created_at with granularity daily, but offset that granularity by -2.5 hours, with the expected result (date, count):

  1. 2025-12-31, 3
  2. 2025-01-01, 1

I can define custom granularities for pre-defined offsets, but I want this to be able to be supplied by clients at query time. This is a viable but non-ideal workaround for supporting hour shifts, but moving to supporting minute shifts causes a significant number of custom granularities and bloats the data model.

This would also be an alternative to supporting weekly aggregations on different starting days of week, without adding 7 custom granularities to every time dimension.

I could pass in a timezone that maps to the required shift - but this is extremely unintuitive to ask a client to do, and doesn't fully solve the problem (for example, I'd still want to respect DST change in the client's actual timezone).

Is there a way to do this with cube today?

Metadata

Metadata

Assignees

Labels

questionThe issue is a question. Please use Stack Overflow for questions.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions