Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
None
-
None
Description
SqlValidatorUtil#deriveNaturalJoinColumnList can't correctly derive common columns for JOIN if the left hand of it is another NATURAL JOIN or JOIN with USING. For example:
SELECT * FROM (values (1, 1)) as t1(a, b) NATURAL JOIN (values (1, 1)) as t2(a, c) NATURAL JOIN (values (1, 1)) as t3(a, d)
Builds incorrect plan:
LogicalProject(A=[$0], B=[$1], C=[$3], A1=[$4], D=[$5]) LogicalJoin(condition=[true], joinType=[inner]) LogicalJoin(condition=[=($0, $2)], joinType=[inner]) LogicalValues(tuples=[[{ 1, 1 }]]) LogicalValues(tuples=[[{ 1, 1 }]]) LogicalValues(tuples=[[{ 1, 1 }]])
Queries with USING also have problems:
SELECT * FROM (values (1, 1)) as t1(a, b) JOIN (values (1, 1)) as t2(a, c) USING (a) JOIN (values (1, 1)) as t3(a, d) USING (a)
Fails with:
Column name 'A' in USING clause is not unique on one side of join
Attachments
Issue Links
- links to