Commit cf988cd
committed
fix: resolver fails to look up CTE columns
Closes #4228.
The resolver fails to infer the type of a CTE column because it only
searches normal tables. My solution is to have two passes, one where
we search the CTE columns first (making them shadow regular tables) then
if not found, we search through regular tables.
We cannot simply add the CTE column in the existing `typeMap` because a
CTE and a regular table will have the same column name which will
trigger the `found > 1` check and the column will be considered
ambiguous. So we use a different typeMap for CTEs so we can separate the
search1 parent b84b1d6 commit cf988cd
9 files changed
Lines changed: 184 additions & 7 deletions
File tree
- internal
- compiler
- endtoend/testdata
- cte_left_join/postgresql/pgx/go
- cte_renamed_column
- postgresql
- go
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
| 31 | + | |
31 | 32 | | |
| 33 | + | |
32 | 34 | | |
33 | 35 | | |
34 | 36 | | |
| |||
67 | 69 | | |
68 | 70 | | |
69 | 71 | | |
70 | | - | |
| 72 | + | |
| 73 | + | |
71 | 74 | | |
72 | 75 | | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
73 | 101 | | |
74 | 102 | | |
75 | 103 | | |
| |||
195 | 223 | | |
196 | 224 | | |
197 | 225 | | |
198 | | - | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
199 | 281 | | |
200 | 282 | | |
201 | 283 | | |
| |||
217 | 299 | | |
218 | 300 | | |
219 | 301 | | |
220 | | - | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
221 | 305 | | |
222 | 306 | | |
223 | 307 | | |
| |||
286 | 370 | | |
287 | 371 | | |
288 | 372 | | |
| 373 | + | |
289 | 374 | | |
290 | 375 | | |
291 | 376 | | |
| |||
475 | 560 | | |
476 | 561 | | |
477 | 562 | | |
| 563 | + | |
478 | 564 | | |
479 | 565 | | |
480 | 566 | | |
| |||
583 | 669 | | |
584 | 670 | | |
585 | 671 | | |
| 672 | + | |
586 | 673 | | |
587 | 674 | | |
588 | 675 | | |
| |||
Lines changed: 2 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
Lines changed: 32 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 29 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 5 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
Lines changed: 5 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
Lines changed: 10 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
0 commit comments