Commit 98fd96c
feat: Rewrite joins from SQL as query-level join hints (cube-js#9561)
This allows to keep join structure in some cases. Consider query like this:
```
SELECT cube2.dim, cube3.dim
FROM cube1
JOIN cube2 ON cube1.__cubeJoinField = cube2.__cubeJoinField
JOIN cube3 ON cube1.__cubeJoinField = cube3.__cubeJoinField
GROUP BY 1, 2
```
It references members only from `cube2` and `cube3`, but join structure actually has `cube1` as root, and it is completely missing from query.
Now every join will generate separate join hint during rewrite, and then they will get to JS side as a query-level join hints.
Supporting changes:
* Remove unused MergedMembersReplacer
* Remove unused rewrite for CrossJoin on empty CubeScan
CubeScan with empty members just should not manifest during rewrites: either it's `AllMembers`, or specific members, but never empty
* Simplify CrossJoin to CubeScan rewrite
* Drop ordering from CubeScan during CrossJoin rewrite
CROSS JOIN does not guarantee same ordering as inputs
* Rewrite join on `__cubeJoinField` directly to CubeScan, without intermediate CrossJoin1 parent ce463cd commit 98fd96c
File tree
22 files changed
+478
-409
lines changed- packages
- cubejs-api-gateway
- src
- types
- cubejs-schema-compiler
- src/adapter
- test/integration/postgres
- rust/cubesql
- cubeclient/src/models
- cubesql/src/compile
- engine/df
- rewrite
- rules
- flatten
- split
- wrapper
- test
22 files changed
+478
-409
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
369 | 369 | | |
370 | 370 | | |
371 | 371 | | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
372 | 376 | | |
373 | 377 | | |
374 | 378 | | |
| |||
412 | 416 | | |
413 | 417 | | |
414 | 418 | | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
415 | 423 | | |
416 | 424 | | |
417 | 425 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
162 | 162 | | |
163 | 163 | | |
164 | 164 | | |
| 165 | + | |
| 166 | + | |
165 | 167 | | |
166 | 168 | | |
167 | 169 | | |
| |||
189 | 191 | | |
190 | 192 | | |
191 | 193 | | |
| 194 | + | |
192 | 195 | | |
193 | 196 | | |
194 | 197 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
122 | 122 | | |
123 | 123 | | |
124 | 124 | | |
| 125 | + | |
| 126 | + | |
125 | 127 | | |
126 | 128 | | |
127 | 129 | | |
| |||
143 | 145 | | |
144 | 146 | | |
145 | 147 | | |
| 148 | + | |
| 149 | + | |
146 | 150 | | |
147 | 151 | | |
148 | 152 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
279 | 279 | | |
280 | 280 | | |
281 | 281 | | |
| 282 | + | |
282 | 283 | | |
283 | 284 | | |
284 | 285 | | |
| |||
329 | 330 | | |
330 | 331 | | |
331 | 332 | | |
| 333 | + | |
332 | 334 | | |
333 | 335 | | |
334 | 336 | | |
| |||
410 | 412 | | |
411 | 413 | | |
412 | 414 | | |
413 | | - | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
414 | 419 | | |
415 | 420 | | |
416 | 421 | | |
| |||
Lines changed: 28 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
641 | 641 | | |
642 | 642 | | |
643 | 643 | | |
| 644 | + | |
| 645 | + | |
| 646 | + | |
| 647 | + | |
| 648 | + | |
| 649 | + | |
| 650 | + | |
| 651 | + | |
| 652 | + | |
| 653 | + | |
| 654 | + | |
| 655 | + | |
| 656 | + | |
| 657 | + | |
| 658 | + | |
| 659 | + | |
| 660 | + | |
| 661 | + | |
| 662 | + | |
| 663 | + | |
| 664 | + | |
| 665 | + | |
| 666 | + | |
| 667 | + | |
| 668 | + | |
| 669 | + | |
| 670 | + | |
| 671 | + | |
644 | 672 | | |
Lines changed: 3 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
| 33 | + | |
| 34 | + | |
33 | 35 | | |
34 | 36 | | |
35 | 37 | | |
| |||
45 | 47 | | |
46 | 48 | | |
47 | 49 | | |
| 50 | + | |
48 | 51 | | |
49 | 52 | | |
50 | 53 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
152 | 152 | | |
153 | 153 | | |
154 | 154 | | |
| 155 | + | |
155 | 156 | | |
156 | 157 | | |
157 | 158 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3368 | 3368 | | |
3369 | 3369 | | |
3370 | 3370 | | |
| 3371 | + | |
| 3372 | + | |
3371 | 3373 | | |
3372 | 3374 | | |
3373 | 3375 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4665 | 4665 | | |
4666 | 4666 | | |
4667 | 4667 | | |
| 4668 | + | |
| 4669 | + | |
| 4670 | + | |
| 4671 | + | |
| 4672 | + | |
| 4673 | + | |
| 4674 | + | |
4668 | 4675 | | |
4669 | 4676 | | |
4670 | 4677 | | |
| |||
4726 | 4733 | | |
4727 | 4734 | | |
4728 | 4735 | | |
| 4736 | + | |
| 4737 | + | |
| 4738 | + | |
| 4739 | + | |
4729 | 4740 | | |
4730 | 4741 | | |
4731 | 4742 | | |
| |||
8218 | 8229 | | |
8219 | 8230 | | |
8220 | 8231 | | |
| 8232 | + | |
| 8233 | + | |
| 8234 | + | |
| 8235 | + | |
8221 | 8236 | | |
8222 | 8237 | | |
8223 | 8238 | | |
| |||
9794 | 9809 | | |
9795 | 9810 | | |
9796 | 9811 | | |
| 9812 | + | |
| 9813 | + | |
| 9814 | + | |
| 9815 | + | |
9797 | 9816 | | |
9798 | 9817 | | |
9799 | 9818 | | |
| |||
11845 | 11864 | | |
11846 | 11865 | | |
11847 | 11866 | | |
| 11867 | + | |
| 11868 | + | |
| 11869 | + | |
| 11870 | + | |
| 11871 | + | |
| 11872 | + | |
11848 | 11873 | | |
11849 | 11874 | | |
11850 | 11875 | | |
| |||
12271 | 12296 | | |
12272 | 12297 | | |
12273 | 12298 | | |
| 12299 | + | |
| 12300 | + | |
| 12301 | + | |
| 12302 | + | |
12274 | 12303 | | |
12275 | 12304 | | |
12276 | 12305 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
15 | | - | |
16 | | - | |
17 | | - | |
18 | | - | |
19 | | - | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
| |||
2002 | 2002 | | |
2003 | 2003 | | |
2004 | 2004 | | |
| 2005 | + | |
| 2006 | + | |
| 2007 | + | |
| 2008 | + | |
| 2009 | + | |
| 2010 | + | |
2005 | 2011 | | |
2006 | 2012 | | |
2007 | 2013 | | |
| |||
0 commit comments