Skip to content

Commit befb2f8

Browse files
authored
docs: Tiny updates (#8912)
* Add a link to Atlas BI Connector deprecation * Fix join relationships. Closes #8758 * Add an example of multiple primary keys
1 parent 4153e4d commit befb2f8

File tree

4 files changed

+115
-17
lines changed

4 files changed

+115
-17
lines changed

docs/pages/product/configuration/data-sources/mongodb.mdx

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,20 @@ redirect_from:
55

66
# MongoDB
77

8+
[MongoDB](https://www.mongodb.com) is a popular document database. It can be
9+
accessed using SQL via the [MongoDB Connector for BI][link-bi-connector], also
10+
known as _BI Connector_.
11+
812
<CommunitySupportedDriver dataSource="MongoDB" />
913

14+
<WarningBox>
15+
16+
BI Connector for MongoDB Atlas, cloud-based MongoDB service, is approaching
17+
[end-of-life](https://www.mongodb.com/docs/atlas/bi-connection/#std-label-bi-connection).
18+
It will be deprecated and no longer supported in June 2025.
19+
20+
</WarningBox>
21+
1022
## Prerequisites
1123

1224
<InfoBox>
@@ -113,3 +125,4 @@ Database][ref-recipe-enable-ssl].
113125
/guides/recipes/data-sources/using-ssl-connections-to-data-source
114126
[ref-schema-ref-types-formats-countdistinctapprox]: /reference/data-model/types-and-formats#count_distinct_approx
115127
[self-preaggs-batching]: #batching
128+
[link-bi-connector]: https://www.mongodb.com/docs/bi-connector/current/

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,10 @@ cubes:
232232
233233
</CodeTabs>
234234
235+
Note that the `id` dimension is defined as a [primary key][ref-ref-primary-key].
236+
It is also possible to have more than one primary key dimension in a cube if
237+
you'd like them all to be parts of a composite key.
238+
235239
[The `line_items` table](#top) also has a couple of dimensions which can be
236240
represented as follows:
237241

@@ -729,5 +733,6 @@ Pre-Aggregations][ref-caching-preaggs-intro].
729733
[ref-pmc]: /product/deployment/cloud/deployment-types#production-multi-cluster
730734
[ref-ref-time-dimensions]: /reference/data-model/types-and-formats#time-1
731735
[ref-ref-dimension-granularities]: /reference/data-model/dimensions#granularities
736+
[ref-ref-primary-key]: /reference/data-model/dimensions#primary_key
732737
[ref-custom-granularity-recipe]: /guides/recipes/data-modeling/custom-granularity
733738
[ref-proxy-granularity]: /product/data-modeling/concepts/calculated-members#time-dimension-granularity

docs/pages/product/data-modeling/concepts/working-with-joins.mdx

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -247,14 +247,6 @@ association in the database, we need to create an associative cube
247247
`post_topics`, and declare the relationships from it to `topics` cube and from
248248
`posts` to `post_topics`.
249249

250-
<InfoBox>
251-
252-
The following example uses the `one_to_many` relationship on the `post_topics`
253-
cube; this causes the direction of joins to be `posts → post_topics → topics`.
254-
[Read more about direction of joins here][self-join-direction].
255-
256-
</InfoBox>
257-
258250
<CodeTabs>
259251

260252
```javascript
@@ -263,7 +255,7 @@ cube(`posts`, {
263255

264256
joins: {
265257
post_topics: {
266-
relationship: `many_to_one`,
258+
relationship: `one_to_many`,
267259
sql: `${CUBE}.id = ${post_topics.post_id}`,
268260
},
269261
},
@@ -286,7 +278,7 @@ cube(`post_topics`, {
286278

287279
joins: {
288280
topic: {
289-
relationship: `one_to_many`,
281+
relationship: `many_to_one`,
290282
sql: `${CUBE}.topic_id = ${topics.id}`,
291283
},
292284
},
@@ -307,7 +299,7 @@ cubes:
307299

308300
joins:
309301
- name: post_topics
310-
relationship: many_to_one
302+
relationship: one_to_many
311303
sql: "{CUBE}.id = {post_topics.post_id}"
312304

313305
- name: topics
@@ -324,7 +316,7 @@ cubes:
324316

325317
joins:
326318
- name: topic
327-
relationship: one_to_many
319+
relationship: many_to_one
328320
sql: "{CUBE}.topic_id = {topics.id}"
329321

330322
dimensions:
@@ -335,6 +327,14 @@ cubes:
335327
336328
</CodeTabs>
337329
330+
<InfoBox>
331+
332+
The following example uses the `many_to_one` relationship on the `post_topics`
333+
cube; this causes the direction of joins to be `posts → post_topics → topics`.
334+
[Read more about direction of joins here][self-join-direction].
335+
336+
</InfoBox>
337+
338338
In scenarios where a table doesn't define a primary key, one can be generated
339339
using SQL:
340340

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

Lines changed: 85 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -264,17 +264,18 @@ cubes:
264264
265265
### `primary_key`
266266

267-
Specify which dimension is a primary key for a cube. The default value is
267+
Specify if a dimension is a primary key for a cube. The default value is
268268
`false`.
269269

270270
A primary key is used to make [joins][ref-schema-ref-joins] work properly.
271271

272-
<WarningBox>
272+
<InfoBox>
273273

274-
Setting `primary_key` to `true` will change the default value of `public`
275-
parameter to `false`. If you still want `public` to be `true`, set it manually.
274+
Setting `primary_key` to `true` will change the default value of the [`public`
275+
parameter](#public) to `false`. If you still want `public` to be `true`, set it
276+
explicitly.
276277

277-
</WarningBox>
278+
</InfoBox>
278279

279280
<CodeTabs>
280281

@@ -306,6 +307,85 @@ cubes:
306307
307308
</CodeTabs>
308309
310+
It is possible to have more than one primary key dimension in a cube if you'd
311+
like them all to be parts of a composite key:
312+
313+
<CodeTabs>
314+
315+
```javascript
316+
cube(`products`, {
317+
sql: `
318+
SELECT 1 AS column_a, 1 AS column_b UNION ALL
319+
SELECT 2 AS column_a, 1 AS column_b UNION ALL
320+
SELECT 1 AS column_a, 2 AS column_b UNION ALL
321+
SELECT 2 AS column_a, 2 AS column_b
322+
`,
323+
324+
dimensions: {
325+
composite_key_a: {
326+
sql: `column_a`,
327+
type: `number`,
328+
primary_key: true
329+
},
330+
331+
composite_key_b: {
332+
sql: `column_b`,
333+
type: `number`,
334+
primary_key: true
335+
}
336+
},
337+
338+
measures: {
339+
count: {
340+
type: `count`
341+
}
342+
}
343+
})
344+
```
345+
346+
```yaml
347+
cubes:
348+
- name: products
349+
sql: >
350+
SELECT 1 AS column_a, 1 AS column_b UNION ALL
351+
SELECT 2 AS column_a, 1 AS column_b UNION ALL
352+
SELECT 1 AS column_a, 2 AS column_b UNION ALL
353+
SELECT 2 AS column_a, 2 AS column_b
354+
355+
dimensions:
356+
- name: composite_key_a
357+
sql: column_a
358+
type: number
359+
primary_key: true
360+
361+
- name: composite_key_b
362+
sql: column_b
363+
type: number
364+
primary_key: true
365+
366+
measures:
367+
- name: count
368+
type: count
369+
```
370+
371+
</CodeTabs>
372+
373+
Querying the `count` measure of the cube shown above will generate the following
374+
SQL to the upstream data source:
375+
376+
```sql
377+
SELECT
378+
count(
379+
CAST("product".column_a as TEXT) || CAST("product".column_b as TEXT)
380+
) "product__count"
381+
FROM (
382+
SELECT 1 AS column_a, 1 AS column_b UNION ALL
383+
SELECT 2 AS column_a, 1 AS column_b UNION ALL
384+
SELECT 1 AS column_a, 2 AS column_b UNION ALL
385+
SELECT 2 AS column_a, 2 AS column_b
386+
) AS "product"
387+
```
388+
309389
### `propagate_filters_to_sub_query`
310390

311391
When this statement is set to `true`, the filters applied to the query will be

0 commit comments

Comments
 (0)