This repository was archived by the owner on Nov 7, 2025. It is now read-only.
Commit 2661385
Review fixes for: #1152
`schema_array_transformer` transforms the SQL query for `Array` columns.
Before this change, if an aggregation was performed on a `Array` column,
e.g. `sum(myArrayColumn)`, the transformer would change it into
`sum(arrayJoin(myArrayColumn))`.
However using `arrayJoin` function has problems - `arrayJoin` modifies
the result set of SQL query introducing additional rows. If there are
many `arrayJoin`s, a Cartesian product many rows will be performed: this
causes query slowdown and makes the result invalid (we don't actually
want to do a Cartesian product!).
Solve the problem by using `-Array` variants of aggregates (e.g.
`sumArray` instead of `sum(arrayJoin())`), which does not inflate the
number of result rows.
Note that this PR does NOT get rid of `arrayJoin()` fully in all cases.
There are panels that actually need it, such as "Top products this week"
in eCommerce dashboard, where we `GROUP BY` an array column.
<img width="1350" alt="Screenshot 2025-01-07 at 11 20 42"
src="https://github.com/user-attachments/assets/214890d5-c04a-4a6a-a683-5bffaf944d80"
/>
This remaining case should use the `ARRAY JOIN` operator, but this is
out-of-scope of this PR.
Closes #1152
---------
Co-authored-by: Piotr Grabowski <[email protected]>
1 parent 9bf027a commit 2661385
File tree
3 files changed
+108
-29
lines changed- quesma/quesma
3 files changed
+108
-29
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
19 | 65 | | |
20 | 66 | | |
21 | 67 | | |
| |||
73 | 119 | | |
74 | 120 | | |
75 | 121 | | |
| 122 | + | |
76 | 123 | | |
77 | 124 | | |
78 | 125 | | |
| |||
81 | 128 | | |
82 | 129 | | |
83 | 130 | | |
84 | | - | |
85 | | - | |
86 | | - | |
87 | | - | |
88 | | - | |
89 | | - | |
90 | | - | |
91 | | - | |
92 | | - | |
93 | | - | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
94 | 135 | | |
| 136 | + | |
| 137 | + | |
95 | 138 | | |
96 | 139 | | |
97 | 140 | | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
98 | 146 | | |
99 | | - | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
100 | 161 | | |
| 162 | + | |
101 | 163 | | |
102 | 164 | | |
103 | 165 | | |
| |||
148 | 210 | | |
149 | 211 | | |
150 | 212 | | |
151 | | - | |
152 | | - | |
153 | | - | |
154 | | - | |
155 | | - | |
156 | | - | |
157 | | - | |
158 | | - | |
159 | | - | |
160 | | - | |
161 | | - | |
162 | | - | |
163 | | - | |
164 | | - | |
165 | | - | |
166 | | - | |
167 | | - | |
168 | 213 | | |
169 | 214 | | |
170 | 215 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
877 | 877 | | |
878 | 878 | | |
879 | 879 | | |
| 880 | + | |
| 881 | + | |
| 882 | + | |
| 883 | + | |
880 | 884 | | |
881 | 885 | | |
882 | 886 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
490 | 490 | | |
491 | 491 | | |
492 | 492 | | |
493 | | - | |
| 493 | + | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
| 512 | + | |
| 513 | + | |
| 514 | + | |
| 515 | + | |
| 516 | + | |
| 517 | + | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
494 | 524 | | |
495 | 525 | | |
496 | 526 | | |
| |||
0 commit comments