File tree Expand file tree Collapse file tree 1 file changed +57
-0
lines changed Expand file tree Collapse file tree 1 file changed +57
-0
lines changed Original file line number Diff line number Diff line change @@ -162,3 +162,60 @@ dimensions: {
162162 }
163163}
164164```
165+
166+ ## Transitive joins
167+
168+ > ** NOTE:** Join graph is directed and ` A-B ` join is different from ` B-A ` . [ Learn more about it here] ( direction-of-joins ) .
169+
170+ Cube.js automatically takes care of transitive joins. For example if you have following schema:
171+
172+ ``` javascript
173+ cube (` A` , {
174+ // ...
175+ joins: {
176+ B : {
177+ sql: ` ${ A } .b_id = ${ B } .id` ,
178+ relationship: ` belongsTo`
179+ }
180+ },
181+
182+ measures: {
183+ count: {
184+ type: ` count`
185+ }
186+ }
187+ });
188+
189+ cube (` B` , {
190+ // ...
191+ joins: {
192+ C : {
193+ sql: ` ${ B } .c_id = ${ C } .id` ,
194+ relationship: ` belongsTo`
195+ }
196+ }
197+ });
198+
199+ cube (` C` , {
200+ // ...
201+
202+ dimensions: {
203+ category: {
204+ sql: ` category` ,
205+ type: ` string`
206+ }
207+ }
208+ });
209+ ```
210+
211+ And following query:
212+
213+ ``` javascript
214+ {
215+ measures: [' A.count' ],
216+ dimensions: [' C.category' ]
217+ }
218+ ```
219+
220+ Joins ` A-B ` and ` B-C ` will be resolved automatically.
221+ Cube.js uses [ Dijkstra algorithm] ( https://en.wikipedia.org/wiki/Dijkstra%27s_algorithm ) to find join path between cubes given requested members.
You can’t perform that action at this time.
0 commit comments