Skip to content

Commit 019837f

Browse files
authored
docs: Elaborate on time dimension column reference in index
1 parent d16af94 commit 019837f

File tree

1 file changed

+50
-2
lines changed

1 file changed

+50
-2
lines changed

docs/docs-new/pages/reference/data-model/pre-aggregations.mdx

Lines changed: 50 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1512,8 +1512,56 @@ from `GROUP BY` last. For range filter columns like `contains`, `>`, `<`, `>=`,
15121512
before `GROUP BY` dimensions. Otherwise, for low selectivity range filters,
15131513
consider putting these columns after `GROUP BY` dimensions.
15141514

1515-
For `original_sql` pre-aggregations, the original column names as strings can be
1516-
used:
1515+
In the case that you want to reference the time dimension in the index, the original column name as a string can be used.
1516+
1517+
<CodeTabs>
1518+
1519+
```javascript
1520+
cube(`orders`, {
1521+
sql_table: `orders`,
1522+
1523+
pre_aggregations: {
1524+
category_and_date: {
1525+
measures: [CUBE.count],
1526+
dimensions: [CUBE.category],
1527+
time_dimension: CUBE.created_at,
1528+
granularity: `day`,
1529+
indexes: {
1530+
category_created_at_index: {
1531+
columns: [CUBE.category, `orders__created_at_day`],
1532+
},
1533+
},
1534+
},
1535+
},
1536+
1537+
// ...
1538+
});
1539+
```
1540+
1541+
```yaml
1542+
cubes:
1543+
- name: orders
1544+
sql_table: orders
1545+
1546+
pre_aggregations:
1547+
- name: category_and_date
1548+
measures:
1549+
- CUBE.count
1550+
dimensions:
1551+
- CUBE.category
1552+
time_dimension: CUBE.created_at
1553+
granularity: day
1554+
indexes:
1555+
- name: category_created_at_index
1556+
columns:
1557+
- CUBE.category
1558+
- orders__created_at_day
1559+
# ...
1560+
```
1561+
1562+
</CodeTabs>
1563+
1564+
The same approach works for `original_sql` pre-aggregations:
15171565

15181566
<CodeTabs>
15191567

0 commit comments

Comments
 (0)