Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

duplicate column names in a table alias should be prevented. #6395

Closed
nicktobey opened this issue Jul 26, 2023 · 0 comments · Fixed by dolthub/go-mysql-server#1965
Closed
Labels
analyzer bug Something isn't working sql Issue with SQL

Comments

@nicktobey
Copy link
Contributor

Repro steps:

drop table if exists ab;
create table ab (a int, b int);
insert into ab values (1, 1), (2, 2);

drop table if exists bc;
create table bc (b int, c int);
insert into bc values (1, 1), (2, 2);

SELECT * FROM (SELECT * FROM ab join bc on ab.b != bc.b) as abc;

SELECT b FROM (SELECT * FROM ab join bc on ab.b != bc.b) as abc;

MySQL results:

ERROR 1060 (42S21) at line 10: Duplicate column name 'b'

Dolt results:

+---+---+---+---+
| a | b | b | c |
+---+---+---+---+
| 2 | 2 | 1 | 1 |
| 1 | 1 | 2 | 2 |
+---+---+---+---+

+---+
| b |
+---+
| 2 |
| 1 |
+---+

In this example, the table alias has two columns named b, and one of them appears to be selected arbitrarily. We should be consistent with MySQL and reject this.

(Mirror of dolthub/go-mysql-server#1881)

@timsehn timsehn added bug Something isn't working sql Issue with SQL labels Jul 26, 2023
@nicktobey nicktobey closed this as not planned Won't fix, can't repro, duplicate, stale Jul 26, 2023
@nicktobey nicktobey reopened this Jul 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
analyzer bug Something isn't working sql Issue with SQL
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants