Commit 85d0bdd
committed
[CALCITE-7663] RelToSqlConverter generates ambiguous column references when expanding SELECT * over a join with duplicate field names
When a dialect's supportGenerateSelectStar() returns false for a join with
duplicate field names, the SELECT * expansion in SqlImplementor did not alias
the expanded columns to their unique row-type field names. A sub-query wrapping
such a join then exposed two identically named columns, making outer references
ambiguous (e.g. PostgreSQL: column reference "id" is ambiguous). Alias each
expanded column to its unique row-type field name, mirroring the validator path.1 parent 85b042c commit 85d0bdd
2 files changed
Lines changed: 72 additions & 3 deletions
File tree
- core/src
- main/java/org/apache/calcite/rel/rel2sql
- test/java/org/apache/calcite/rel/rel2sql
Lines changed: 30 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
296 | 296 | | |
297 | 297 | | |
298 | 298 | | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
299 | 311 | | |
300 | 312 | | |
301 | 313 | | |
| |||
2029 | 2041 | | |
2030 | 2042 | | |
2031 | 2043 | | |
| 2044 | + | |
| 2045 | + | |
| 2046 | + | |
| 2047 | + | |
| 2048 | + | |
2032 | 2049 | | |
2033 | 2050 | | |
2034 | | - | |
| 2051 | + | |
| 2052 | + | |
| 2053 | + | |
| 2054 | + | |
2035 | 2055 | | |
2036 | 2056 | | |
2037 | 2057 | | |
| |||
2392 | 2412 | | |
2393 | 2413 | | |
2394 | 2414 | | |
| 2415 | + | |
| 2416 | + | |
| 2417 | + | |
| 2418 | + | |
| 2419 | + | |
2395 | 2420 | | |
2396 | 2421 | | |
2397 | | - | |
| 2422 | + | |
| 2423 | + | |
| 2424 | + | |
| 2425 | + | |
2398 | 2426 | | |
2399 | 2427 | | |
2400 | 2428 | | |
| |||
Lines changed: 42 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9669 | 9669 | | |
9670 | 9670 | | |
9671 | 9671 | | |
| 9672 | + | |
| 9673 | + | |
| 9674 | + | |
9672 | 9675 | | |
9673 | 9676 | | |
9674 | 9677 | | |
9675 | 9678 | | |
9676 | | - | |
| 9679 | + | |
9677 | 9680 | | |
9678 | 9681 | | |
9679 | 9682 | | |
9680 | 9683 | | |
9681 | 9684 | | |
9682 | 9685 | | |
9683 | 9686 | | |
| 9687 | + | |
| 9688 | + | |
| 9689 | + | |
| 9690 | + | |
| 9691 | + | |
| 9692 | + | |
| 9693 | + | |
| 9694 | + | |
| 9695 | + | |
| 9696 | + | |
| 9697 | + | |
| 9698 | + | |
| 9699 | + | |
| 9700 | + | |
| 9701 | + | |
| 9702 | + | |
| 9703 | + | |
| 9704 | + | |
| 9705 | + | |
| 9706 | + | |
| 9707 | + | |
| 9708 | + | |
| 9709 | + | |
| 9710 | + | |
| 9711 | + | |
| 9712 | + | |
| 9713 | + | |
| 9714 | + | |
| 9715 | + | |
| 9716 | + | |
| 9717 | + | |
| 9718 | + | |
| 9719 | + | |
| 9720 | + | |
| 9721 | + | |
| 9722 | + | |
| 9723 | + | |
| 9724 | + | |
9684 | 9725 | | |
9685 | 9726 | | |
9686 | 9727 | | |
| |||
0 commit comments