Commit f962686
authored
fix: Fix bug with structurally equal correlated subqueries (#22313)
## Which issue does this PR close?
- Closes #21210.
## Rationale for this change
If a query contained two or more structurally equal correlated
subqueries, we previously would produce incorrect query results. This
was caused by using `Subquery` as a hashmap key; if we use the subquery
alias instead, we can avoid the unintended key collision. Using the
alias (a string) as the hashmap key is also safer and more efficient
than hashing on a complex type like `Subquery`.
## What changes are included in this PR?
* Fix for bug in `ScalarSubqueryToJoin` rewrite pass
* SLT test
## Are these changes tested?
Yes, with new test added.
## Are there any user-facing changes?
No, aside from fixing the previously incorrect query results.1 parent bbf9078 commit f962686
2 files changed
Lines changed: 30 additions & 19 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
153 | 153 | | |
154 | 154 | | |
155 | 155 | | |
156 | | - | |
157 | | - | |
158 | | - | |
159 | | - | |
160 | | - | |
161 | | - | |
162 | | - | |
163 | | - | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
164 | 161 | | |
165 | | - | |
166 | | - | |
| 162 | + | |
| 163 | + | |
167 | 164 | | |
168 | 165 | | |
169 | | - | |
| 166 | + | |
170 | 167 | | |
171 | 168 | | |
172 | 169 | | |
| |||
180 | 177 | | |
181 | 178 | | |
182 | 179 | | |
183 | | - | |
184 | | - | |
| 180 | + | |
185 | 181 | | |
186 | | - | |
| 182 | + | |
187 | 183 | | |
188 | 184 | | |
189 | 185 | | |
| |||
197 | 193 | | |
198 | 194 | | |
199 | 195 | | |
200 | | - | |
| 196 | + | |
201 | 197 | | |
202 | 198 | | |
203 | 199 | | |
| |||
206 | 202 | | |
207 | 203 | | |
208 | 204 | | |
209 | | - | |
| 205 | + | |
210 | 206 | | |
211 | | - | |
212 | 207 | | |
213 | 208 | | |
214 | | - | |
| 209 | + | |
215 | 210 | | |
216 | | - | |
| 211 | + | |
217 | 212 | | |
218 | 213 | | |
219 | 214 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
851 | 851 | | |
852 | 852 | | |
853 | 853 | | |
| 854 | + | |
| 855 | + | |
| 856 | + | |
| 857 | + | |
| 858 | + | |
| 859 | + | |
| 860 | + | |
| 861 | + | |
| 862 | + | |
| 863 | + | |
| 864 | + | |
| 865 | + | |
| 866 | + | |
| 867 | + | |
| 868 | + | |
| 869 | + | |
854 | 870 | | |
855 | 871 | | |
856 | 872 | | |
| |||
0 commit comments