You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@calcite.apache.org by "zhen wang (JIRA)" <ji...@apache.org> on 2017/05/27 09:18:04 UTC
[jira] [Commented] (CALCITE-1154) Wrong Plan/Result if wrapping a
query with SELECT * FROM
[ https://issues.apache.org/jira/browse/CALCITE-1154?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16027368#comment-16027368 ]
zhen wang commented on CALCITE-1154:
------------------------------------
it does look like `SELECT * is not validated and 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)