Skip to content

Commit 93d427e

Browse files
authored
docs: Hierarchies and folders in the data model (#9106)
* Hierarchies reference * All the rest * Fix * Fix
1 parent 0e14d6f commit 93d427e

File tree

14 files changed

+511
-83
lines changed

14 files changed

+511
-83
lines changed

docs/pages/guides/style-guide.mdx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,8 @@ cube_project
7373
- `pre_aggregations`
7474
- `joins`
7575
- `dimensions`
76+
- `hierarchies`
77+
- `segments`
7678
- `measures`
7779

7880
### Dimensions & measures
@@ -136,8 +138,9 @@ cubes:
136138
- Applicable [view parameters][ref-view-params] should be ordered as follows:
137139
- `name`
138140
- `description`
139-
- `includes`
141+
- `public`
140142
- `cubes`
143+
- `folders`
141144

142145
### Example view
143146

@@ -316,7 +319,7 @@ cube(`users`, {
316319

317320
This style guide was inspired in part by:
318321

319-
- [Brooklyn Data' SQL style guide](https://github.com/brooklyn-data/co/blob/main/sql_style_guide.md)
322+
- [Brooklyn Data Co. SQL style guide](https://github.com/brooklyn-data/co/blob/main/sql_style_guide.md)
320323
- [LAMS Style Guide](https://looker-open-source.github.io/look-at-me-sideways/rules.html)
321324

322325
[cpn]: https://cube.dev/consulting/cube-partner-network

docs/pages/product/apis-integrations.mdx

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,16 @@ for an unofficial, community-maintained [client library for Python](https://gith
4848

4949
</ReferenceBox>
5050

51+
### Support for data modeling
52+
53+
Support for data modeling features differ across APIs, integrations, and [visualization
54+
tools][ref-viz-tools]. Some of the features with partial support are listed below:
55+
56+
| Feature | Supported in | Not supported in |
57+
| --- | --- | --- |
58+
| [Hierarchies][ref-hierarchies] |[Tableau][ref-tableau] via [Semantic Layer Sync][ref-sls]<br/>✅ Cube Cloud for Excel<br/>✅ [Cube Cloud for Sheets][ref-cube-cloud-for-sheets] | ❌ All other tools |
59+
| [Folders][ref-folders] |[Tableau][ref-tableau] via [Semantic Layer Sync][ref-sls]<br/>✅ Cube Cloud for Excel<br/>✅ [Cube Cloud for Sheets][ref-cube-cloud-for-sheets] | ❌ All other tools |
60+
5161
## Management APIs
5262

5363
In case you'd like Cube to work with data orchestration tools and let them push
@@ -69,4 +79,8 @@ API][ref-orchestration-api].
6979
[ref-sql-syntax]: /product/apis-integrations/sql-api#querying-fundamentals
7080
[ref-json-syntax]: /product/apis-integrations/rest-api/query-format
7181
[ref-graphql-syntax]: /product/apis-integrations/graphql-api#getting-started
72-
[ref-cube-cloud-for-sheets]: /product/apis-integrations/google-sheets
82+
[ref-cube-cloud-for-sheets]: /product/apis-integrations/google-sheets
83+
[ref-viz-tools]: /product/configuration/visualization-tools
84+
[ref-hierarchies]: /reference/data-model/hierarchies
85+
[ref-folders]: /reference/data-model/view#folders
86+
[ref-tableau]: /product/configuration/visualization-tools/tableau

docs/pages/product/apis-integrations/mdx-api.mdx

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,14 @@ views:
6060
- city
6161
```
6262
63+
<InfoBox>
64+
65+
For historical reasons, the syntax shown above differ from how
66+
[hierarchies][ref-hierarchies] are supposed to be defined in the data model.
67+
This is going to be harmonized in the future.
68+
69+
</InfoBox>
70+
6371
### Dimension keys
6472
6573
You can define a member that will be used as a key for a dimension in the cube's model file.
@@ -143,6 +151,18 @@ views:
143151
- completed_percentage
144152
```
145153
154+
<InfoBox>
155+
156+
For historical reasons, the syntax shown above differ from how
157+
[folders][ref-folders] are supposed to be defined in the data model.
158+
This is going to be harmonized in the future.
159+
160+
</InfoBox>
161+
146162
## Authentication and authorization
147163
148164
Authentication and authorization work the same as for the [SQL API](/product/apis-integrations/sql-api/security).
165+
166+
167+
[ref-hierarchies]: /reference/data-model/hierarchies
168+
[ref-folders]: /reference/data-model/view#folders

docs/pages/product/caching/matching-pre-aggregations.mdx

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,18 @@ If you don't know why a query doesn't match a pre-aggregation, check
2121

2222
## Eligible pre-aggregations
2323

24-
Cube will search for matching pre-aggregations in all cubes that define
25-
members in the query.
26-
27-
Pre-aggregations are tested in the order they are defined in the data model
24+
Cube goes through the following steps to determine if there are any pre-aggregations
25+
matching a query:
26+
- **Members (e.g., dimensions, measures, etc.) are extracted from the query.**
27+
If the query contains members of a [view][ref-views], they are substituted by
28+
respective members of cubes where they are defined. It means that pre-aggregations
29+
defined for cube members would also match queries with view members. There's no need
30+
to define additional pre-aggregations for views.
31+
- Cube looks for pre-aggregations in all cubes that define members in the query.
32+
- Pre-aggregations are tested in the order they are defined in the data model
2833
file. However, `rollup` pre-aggregations are tested before `original_sql`
2934
pre-aggregations.
30-
31-
The first pre-aggregation that matches a query is used.
35+
- The first pre-aggregation that [matches](#matching-algorithm) a query is used.
3236

3337
## Matching algorithm
3438

@@ -129,4 +133,5 @@ configuration option.
129133
[ref-conf-scheduled-refresh-time-zones]: /reference/configuration/config#scheduled_refresh_time_zones
130134
[ref-ungrouped-queries]: /product/apis-integrations/queries#ungrouped-query
131135
[ref-primary-key]: /reference/data-model/dimensions#primary_key
132-
[ref-custom-granularity]: /reference/data-model/dimensions#granularities
136+
[ref-custom-granularity]: /reference/data-model/dimensions#granularities
137+
[ref-views]: /product/data-modeling/concepts#views

docs/pages/product/data-modeling/concepts.mdx

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ redirect_from:
55

66
# Concepts
77

8-
Cube borrows a lot of terminology from data science and [OLAP
8+
Cube borrows a lot of terminology from [OLAP
99
theory][wiki-olap], and this document is intended for both newcomers and regular
1010
users to refresh their understanding.
1111

@@ -109,8 +109,10 @@ paths.
109109
110110
<Diagram src="https://ucarecdn.com/bfc3e04a-b690-40bc-a6f8-14a9175fb4fd/" />
111111
112-
Views can **not** have their own members. Instead, use the `cubes` or `includes`
113-
parameters to include measures and dimensions from other cubes into the view.
112+
Views can **not** have their own members. Instead, they use the `cubes`
113+
parameter to include members of cubes. Optionally, you can also group members of a view
114+
into [folders][ref-ref-folders].
115+
114116
In the example below, we create the `orders` view which includes select members
115117
from `base_orders`, `products`, and `users` cubes:
116118

@@ -178,7 +180,7 @@ views:
178180
</CodeTabs>
179181
180182
Views do **not** define any [pre-aggregations](#pre-aggregations). Instead,
181-
they reuse pre-aggregations from underlying cubes.
183+
they [reuse][ref-matching-preaggs] pre-aggregations from underlying cubes.
182184
183185
View may not only be defined statically; you can actually build
184186
[dynamic data models][ref-dynamic-data-models].
@@ -282,7 +284,9 @@ cubes:
282284
283285
</CodeTabs>
284286
285-
Also, [subquery dimensions][ref-subquery-dimensions] can be used to join cubes
287+
If needed, dimensions can be organized into [hierarchies][ref-ref-hierarchies].
288+
Also, [proxy dimensions][ref-proxy-dimensions] are helpful for code reusability
289+
and [subquery dimensions][ref-subquery-dimensions] can be used to join cubes
286290
implicitly.
287291
288292
### Dimension types
@@ -434,6 +438,9 @@ cubes:
434438
435439
</CodeTabs>
436440
441+
Also, [calculated measures][ref-calculated-measures] can be used to perform calculations
442+
on other measures.
443+
437444
### Measure types
438445
439446
Measures can be of different types. See the [measure type
@@ -719,6 +726,7 @@ Pre-Aggregations][ref-caching-preaggs-intro].
719726
[ref-polymorphic-cubes]: /product/data-modeling/concepts/polymorphic-cubes
720727
[ref-data-blending]: /product/data-modeling/concepts/data-blending
721728
[ref-dynamic-data-models]: /product/data-modeling/dynamic
729+
[ref-proxy-dimensions]: /product/data-modeling/concepts/calculated-members#proxy-dimensions
722730
[ref-subquery-dimensions]: /product/data-modeling/concepts/calculated-members#subquery-dimensions
723731
[ref-working-with-joins]: /product/data-modeling/concepts/working-with-joins
724732
[self-dimensions]: #dimensions
@@ -735,4 +743,6 @@ Pre-Aggregations][ref-caching-preaggs-intro].
735743
[ref-ref-dimension-granularities]: /reference/data-model/dimensions#granularities
736744
[ref-ref-primary-key]: /reference/data-model/dimensions#primary_key
737745
[ref-custom-granularity-recipe]: /guides/recipes/data-modeling/custom-granularity
738-
[ref-proxy-granularity]: /product/data-modeling/concepts/calculated-members#time-dimension-granularity
746+
[ref-proxy-granularity]: /product/data-modeling/concepts/calculated-members#time-dimension-granularity
747+
[ref-ref-hierarchies]: /reference/data-model/hierarchies
748+
[ref-ref-folders]: /reference/data-model/view#folders

docs/pages/product/workspace/playground.mdx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@ on a cube or a view to view a list of its members.
4242
src="https://ucarecdn.com/08d5cc69-431d-43d9-8da4-804029adf1fa/"
4343
/>
4444

45-
Measures, dimensions, and segments are shown using distinct colors. If a member has
45+
Members of cubes and views (i.e., measures, dimensions, hierarchies, etc.) are shown
46+
using distinct colors and icons. If a member has
4647
a [title][ref-data-model-title] or a [description][ref-data-model-description] set
4748
in the data model, they will be shown in a tooltip. If a member is not
4849
[public][ref-data-model-public], you will see a lock sign next to it.

docs/pages/reference/data-model/_meta.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ module.exports = {
33
"view": "Views",
44
"measures": "Measures",
55
"dimensions": "Dimensions",
6+
"hierarchies": "Hierarchies",
67
"segments": "Segments",
78
"joins": "Joins",
89
"pre-aggregations": "Pre-aggregations",

docs/pages/reference/data-model/cube.mdx

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,9 @@ A `cube` represents a table of data in Cube.
1010

1111
Cubes are typically declared in separate files with one cube per file.
1212
Within each cube are definitions of [measures][ref-ref-measures],
13-
[dimensions][ref-ref-dimensions], [segments][ref-ref-segments],
14-
[joins][ref-ref-joins] between cubes, and [pre-aggregations][ref-ref-pre-aggs].
13+
[dimensions][ref-ref-dimensions], [hierarchies][ref-ref-hierarchies],
14+
[segments][ref-ref-segments], [joins][ref-ref-joins] between cubes,
15+
and [pre-aggregations][ref-ref-pre-aggs].
1516

1617
<CodeTabs>
1718

@@ -277,13 +278,7 @@ cube(`extended_order_facts`, {
277278

278279
### `public`
279280

280-
<InfoBox>
281-
282-
Prior to v0.33, this property was called `shown`.
283-
284-
</InfoBox>
285-
286-
The `public` property is used to manage the visibility of a cube. Valid values
281+
The `public` parameter is used to manage the visibility of a cube. Valid values
287282
for `public` are `true` and `false`. When set to `false`, this cube **cannot**
288283
be queried through the API. Defaults to `true`.
289284

@@ -599,6 +594,7 @@ cubes:
599594
[ref-apis]: /product/apis-integrations
600595
[ref-ref-measures]: /reference/data-model/measures
601596
[ref-ref-dimensions]: /reference/data-model/dimensions
597+
[ref-ref-hierarchies]: /reference/data-model/hierarchies
602598
[ref-ref-segments]: /reference/data-model/segments
603599
[ref-ref-joins]: /reference/data-model/joins
604600
[ref-ref-pre-aggs]: /reference/data-model/pre-aggregations

docs/pages/reference/data-model/dimensions.mdx

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@ The `dimensions` property contains a set of dimensions. You can think about a
1010
dimension as an attribute related to a measure, e.g. the measure `user_count`
1111
can have dimensions like `country`, `age`, `occupation`, etc.
1212

13-
Any dimension should have the following properties: `name`, `sql` and `type`.
13+
Any dimension should have the following parameters: `name`, `sql` and `type`.
14+
15+
Dimensions can be also organized into [hierarchies][ref-ref-hierarchies].
1416

1517
## Parameters
1618

@@ -425,13 +427,7 @@ cubes:
425427
426428
### `public`
427429

428-
<InfoBox>
429-
430-
Prior to v0.33, this property was called `shown`.
431-
432-
</InfoBox>
433-
434-
The `public` property is used to manage the visibility of a dimension. Valid
430+
The `public` parameter is used to manage the visibility of a dimension. Valid
435431
values for `public` are `true` and `false`. When set to `false`, this dimension
436432
**cannot** be queried through the API. Defaults to `true`.
437433

@@ -715,4 +711,5 @@ cube(`orders`, {
715711
[ref-apis]: /product/apis-integrations
716712
[ref-time-dimensions]: /reference/data-model/types-and-formats#time-1
717713
[link-date-time-string]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date#date_time_string_format
718-
[ref-custom-granularity-recipe]: /guides/recipes/data-modeling/custom-granularity
714+
[ref-custom-granularity-recipe]: /guides/recipes/data-modeling/custom-granularity
715+
[ref-ref-hierarchies]: /reference/data-model/hierarchies

0 commit comments

Comments
 (0)