Valid join query erroneously reported as ambiguous
nicktobey opened this issue · 1 comments
nicktobey commented
Reproduction steps:
create table a (b int);
create table c (d int);
select * from a join c c1 on b = d join c c2 on c1.d = c2.d;
MySql result: query runs
GMS output:
ambiguous column name "d", it's present in all these tables: c1, c2
We seem to be trying to resolve the references in b = d
in the context of the complete 3-way join, even though it should be resolved just in the context of a join c c1
Out of curiosity I changed the query to:
select * from a join c c1 on b = c2.d join c c2 on c1.d = c2.d;
This is an invalid query and MySQL recognizes it as such:
Unknown column 'c2.d' in 'on clause'
GMS also fails but with a different, nonsensical error:
table "c2" does not have column "d"
(table c2, does, in fact, have a column d. Perhaps it returns this error because it thinks the table exists but the column doesn't.)
timsehn commented
We should make these types of issues in Dolt for visibility and tag them with label analyzer.
GMS issues are reserved for issues that only effect GMS, not Dolt.