[ https://issues.apache.org/jira/browse/CALCITE-1154?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16027368#comment-16027368 ]
zhen wang edited comment on CALCITE-1154 at 5/27/17 9:25 AM: ------------------------------------------------------------- it does look like `SELECT * is not validated properly` here is my parsing tree {code} SELECT `EXPR$0`.`deptno`, `EXPR$0`.`deptno` AS `deptno0` FROM (SELECT `T1`.`deptno`, `T2`.`deptno` FROM `hr`.`emps` AS `T1` INNER JOIN `hr`.`depts` AS `T2` ON `T1`.`empid` = `T2`.`deptno`) AS `EXPR$0` {code} was (Author: zhenw): it does look like `SELECT * is not parsed properly` here is my parsing tree {code} SELECT `EXPR$0`.`deptno`, `EXPR$0`.`deptno` AS `deptno0` FROM (SELECT `T1`.`deptno`, `T2`.`deptno` FROM `hr`.`emps` AS `T1` INNER JOIN `hr`.`depts` AS `T2` ON `T1`.`empid` = `T2`.`deptno`) AS `EXPR$0` {code} > Wrong Plan/Result if wrapping a query with SELECT * FROM > -------------------------------------------------------- > > Key: CALCITE-1154 > URL: https://issues.apache.org/jira/browse/CALCITE-1154 > Project: Calcite > Issue Type: Bug > Components: core > Reporter: Sean Hsuan-Yi Chu > Assignee: Sean Hsuan-Yi Chu > > For example, a query such as > {code} > select * from ( > select t1.deptno, t2.deptno > from emp t1 inner join dept t2 > on t1.empno = t2.deptno > ) > {code} > gives a plan: > {code} > LogicalProject(DEPTNO=[$0], DEPTNO0=[$0]) > LogicalProject(DEPTNO=[$7], DEPTNO0=[$9]) > LogicalJoin(condition=[=($0, $9)], joinType=[inner]) > LogicalTableScan(table=[[CATALOG, SALES, EMP]]) > LogicalTableScan(table=[[CATALOG, SALES, DEPT]]) > {code} > As the top LogicalProject indicates, although DEPTNO and DEPTNO0 coming from > different tables, Calcite thinks they are the same so just pick $0. > Notice if we remove the outermost select * where (), Calcite would not be > confused with those two columns. -- This message was sent by Atlassian JIRA (v6.3.15#6346)