[ 
https://issues.apache.org/jira/browse/CALCITE-4921?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17862556#comment-17862556
 ] 

Pavel Pereslegin commented on CALCITE-4921:
-------------------------------------------

The listed test cases passed successfully after CALCITE-5171 and CALCITE-5253.

> Nested NATURAL JOINs or JOINs with USING can't find common column
> -----------------------------------------------------------------
>
>                 Key: CALCITE-4921
>                 URL: https://issues.apache.org/jira/browse/CALCITE-4921
>             Project: Calcite
>          Issue Type: Bug
>            Reporter: Aleksey Plekhanov
>            Priority: Major
>
> {{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:
> {noformat}
> 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){noformat}
> Builds incorrect plan:
> {noformat}
> 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 }]]){noformat}
> Queries with USING also have problems:
> {noformat}
> 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){noformat}
> Fails with:
> {noformat}
> Column name 'A' in USING clause is not unique on one side of join{noformat}



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to