Skip to content

Commit dd6810d

Browse files
committed
docs: Add time_dimensions parameter to pre-aggregations reference
Added documentation for the time_dimensions parameter which allows defining multiple time dimensions with individual granularities for a single pre-aggregation. Changes: - Added new time_dimensions section after granularity section - Included code examples in both JavaScript and YAML - Added note in time_dimension section linking to time_dimensions - Added reference link for internal navigation
1 parent 9274201 commit dd6810d

File tree

1 file changed

+94
-0
lines changed

1 file changed

+94
-0
lines changed

docs/pages/product/data-modeling/reference/pre-aggregations.mdx

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -647,6 +647,13 @@ cubes:
647647
A [`granularity`][self-granularity] **must** also be included in the
648648
pre-aggregation definition.
649649

650+
<InfoBox>
651+
652+
To define multiple time dimensions for a single pre-aggregation, use the
653+
[`time_dimensions`][self-timedimensions] property instead.
654+
655+
</InfoBox>
656+
650657
### `granularity`
651658

652659
The `granularity` property defines the time dimension granularity of data
@@ -694,6 +701,92 @@ The value can be either a default granularity (i.e., `second`, `minute`, `hour`,
694701
granularity][ref-custom-granularity]. This property is required when using
695702
[`time_dimension`][self-timedimension].
696703

704+
### `time_dimensions`
705+
706+
The `time_dimensions` property allows you to define multiple time dimensions for
707+
a single pre-aggregation. Each time dimension is specified with its own
708+
granularity. This is useful when you need to pre-aggregate data based on
709+
multiple time columns.
710+
711+
<CodeTabs>
712+
713+
```javascript
714+
cube(`orders`, {
715+
sql_table: `orders`,
716+
717+
pre_aggregations: {
718+
multiple_time_dimensions: {
719+
measures: [CUBE.count],
720+
time_dimensions: [
721+
{
722+
dimension: CUBE.created_at,
723+
granularity: `day`
724+
},
725+
{
726+
dimension: CUBE.completed_at,
727+
granularity: `day`
728+
}
729+
],
730+
partition_granularity: `month`
731+
}
732+
},
733+
734+
measures: {
735+
count: {
736+
type: `count`
737+
}
738+
},
739+
740+
dimensions: {
741+
created_at: {
742+
type: `time`,
743+
sql: `created_at`
744+
},
745+
746+
completed_at: {
747+
type: `time`,
748+
sql: `completed_at`
749+
}
750+
}
751+
})
752+
```
753+
754+
```yaml
755+
cubes:
756+
- name: orders
757+
sql_table: orders
758+
759+
pre_aggregations:
760+
- name: multiple_time_dimensions
761+
measures:
762+
- count
763+
time_dimensions:
764+
- dimension: created_at
765+
granularity: day
766+
- dimension: completed_at
767+
granularity: day
768+
partition_granularity: month
769+
770+
measures:
771+
- name: count
772+
type: count
773+
774+
dimensions:
775+
- name: created_at
776+
type: time
777+
sql: created_at
778+
779+
- name: completed_at
780+
type: time
781+
sql: completed_at
782+
```
783+
784+
</CodeTabs>
785+
786+
When using `time_dimensions`, you cannot use the [`time_dimension`][self-timedimension]
787+
or [`granularity`][self-granularity] properties, as each time dimension defines
788+
its own granularity.
789+
697790
### `segments`
698791

699792
The `segments` property is an array of [segments from the
@@ -1755,6 +1848,7 @@ cubes:
17551848
[self-rollupjoin]: #rollup_join
17561849
[self-rolluplambda]: #rollup_lambda
17571850
[self-timedimension]: #time_dimension
1851+
[self-timedimensions]: #time_dimensions
17581852
[self-buildrange]: #build_range_start-and-build_range_end
17591853
[wiki-olap-ops]: https://en.wikipedia.org/wiki/OLAP_cube#Operations
17601854
[wiki-composable-agg-fn]:

0 commit comments

Comments
 (0)