[ https://issues.apache.org/jira/browse/CALCITE-5583?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
libopeng updated CALCITE-5583: ------------------------------ Description: Rel2Sql will get an error when select * and join is present {code:java} LogicalJoin(condition=[=($0, $1)], joinType=[inner]) LogicalProject(c0=[$0]) LogicalTableScan(table=[[scott, EMP]]) LogicalProject(c0=[$0]) LogicalTableScan(table=[[scott, EMP]]) {code} to sql {code:java} SELECT * FROM (SELECT "EMPNO" AS "c0" FROM "scott"."EMP") AS "t" INNER JOIN (SELECT "EMPNO" AS "c0" FROM "scott"."EMP") AS "t0" ON "t"."c0" = "t0"."c0" {code} When this sql is a subquery, it can be wrong {code:java} select * from "EMPNO" t1 left join ( SELECT * FROM (SELECT "EMPNO" AS "c0" FROM "scott"."EMP") AS "t" INNER JOIN (SELECT "EMPNO" AS "c0" FROM "scott"."EMP") AS "t0" ON "t"."c0" = "t0"."c0" ) t2 on t1.EMPNO=t2."c0"{code} {color:#ff0000}fault: 'column reference "c0" is ambiguous' error when executing in postgresql{color} {color:#172b4d}[https://github.com/apache/calcite/blob/main/core/src/main/java/org/apache/calcite/rel/rel2sql/RelToSqlConverter.java#L451]{color} {color:#172b4d}Why add !isStar judgment here{color} was: Rel2Sql will get an error when select * and join is present {code:java} LogicalJoin(condition=[=($0, $1)], joinType=[inner]) LogicalProject(c0=[$0]) LogicalTableScan(table=[[scott, EMP]]) LogicalProject(c0=[$0]) LogicalTableScan(table=[[scott, EMP]]) {code} to sql {code:java} SELECT * FROM (SELECT "EMPNO" AS "c0" FROM "scott"."EMP") AS "t" INNER JOIN (SELECT "EMPNO" AS "c0" FROM "scott"."EMP") AS "t0" ON "t"."c0" = "t0"."c0" {code} When this sql is a subquery, it can be wrong {code:java} select * from "EMPNO" t1 left join ( SELECT * FROM (SELECT "EMPNO" AS "c0" FROM "scott"."EMP") AS "t" INNER JOIN (SELECT "EMPNO" AS "c0" FROM "scott"."EMP") AS "t0" ON "t"."c0" = "t0"."c0" ) t2 on t1.EMPNO=t2."c0"{code} {color:#FF0000}fault: 'column reference "c0" is ambiguous' error when executing in postgresql{color} > Rel2Sql will get an error when select * and join is present > ----------------------------------------------------------- > > Key: CALCITE-5583 > URL: https://issues.apache.org/jira/browse/CALCITE-5583 > Project: Calcite > Issue Type: Bug > Reporter: libopeng > Priority: Major > > Rel2Sql will get an error when select * and join is present > {code:java} > LogicalJoin(condition=[=($0, $1)], joinType=[inner]) > LogicalProject(c0=[$0]) > LogicalTableScan(table=[[scott, EMP]]) > LogicalProject(c0=[$0]) > LogicalTableScan(table=[[scott, EMP]]) {code} > to sql > {code:java} > SELECT * > FROM (SELECT "EMPNO" AS "c0" > FROM "scott"."EMP") AS "t" > INNER JOIN (SELECT "EMPNO" AS "c0" > FROM "scott"."EMP") AS "t0" ON "t"."c0" = "t0"."c0" {code} > When this sql is a subquery, it can be wrong > {code:java} > select * > from "EMPNO" t1 > left join ( > SELECT * FROM (SELECT "EMPNO" AS "c0" FROM "scott"."EMP") AS "t" INNER JOIN > (SELECT "EMPNO" AS "c0" FROM "scott"."EMP") AS "t0" ON "t"."c0" = "t0"."c0" > ) t2 > on t1.EMPNO=t2."c0"{code} > {color:#ff0000}fault: 'column reference "c0" is ambiguous' error when > executing in postgresql{color} > {color:#172b4d}[https://github.com/apache/calcite/blob/main/core/src/main/java/org/apache/calcite/rel/rel2sql/RelToSqlConverter.java#L451]{color} > {color:#172b4d}Why add !isStar judgment here{color} -- This message was sent by Atlassian Jira (v8.20.10#820010)