Commit be44a57
committed
fix(compiler): handle subqueries in JOIN nullability inference
Fixed incorrect nullability inference when using subqueries with LEFT/RIGHT/FULL OUTER JOINs.
When using subqueries in JOINs like:
SELECT * FROM a LEFT JOIN (SELECT * FROM b) si ON si.a_id = a.id
Columns from subquery 'si' were incorrectly treated as NOT NULL.
Root cause: The isTableRequired() function did not handle *ast.RangeSubselect (subquery ranges).
Solution:
- Added *ast.RangeSubselect case to isTableRequired()
- Match subqueries by their alias names
- Verified all JOIN types (LEFT/RIGHT/FULL OUTER) work correctly
Test coverage:
- Added internal/endtoend/testdata/join_left_subquery/postgresql/
- Covers LEFT JOIN, RIGHT JOIN, and FULL OUTER JOIN patterns
Fixes #41171 parent 2e0435c commit be44a57
File tree
7 files changed
+337
-0
lines changed- internal
- compiler
- endtoend/testdata/join_left_subquery/postgresql
- go
7 files changed
+337
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
424 | 424 | | |
425 | 425 | | |
426 | 426 | | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
427 | 434 | | |
428 | 435 | | |
429 | 436 | | |
| |||
Lines changed: 31 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 22 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 229 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 25 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
Lines changed: 11 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
Lines changed: 12 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
0 commit comments