You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@calcite.apache.org by "Julian Hyde (JIRA)" <ji...@apache.org> on 2017/05/22 19:35:04 UTC

[jira] [Commented] (CALCITE-1799) OR IN Subquery conversion wrong

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

Julian Hyde commented on CALCITE-1799:
--------------------------------------

There are two ways to deal with sub-queries. The new way is to disabling sub-query conversion in SqlToRelConverter, which causes RexSubQuery expressions to be created, which are then handled by SubQueryRemoveRule. (Search for tests that call {{withLateDecorrelation}}.) Does the problem exist if you do things the new way?

> OR IN Subquery conversion wrong
> -------------------------------
>
>                 Key: CALCITE-1799
>                 URL: https://issues.apache.org/jira/browse/CALCITE-1799
>             Project: Calcite
>          Issue Type: Bug
>          Components: core
>    Affects Versions: 1.12.0
>            Reporter: Gian Merlino
>            Assignee: Julian Hyde
>              Labels: sub-query
>
> This query:
> {code}
> select * from emp where deptno = 10 or deptno in (
>     select dept.deptno from dept where deptno < 5)
> {code}
> Is converted to this by SqlToRelConverter:
> {code}
> LogicalProject(EMPNO=[$0], ENAME=[$1], JOB=[$2], MGR=[$3], HIREDATE=[$4], SAL=[$5], COMM=[$6], DEPTNO=[$7], SLACKER=[$8])
>   LogicalFilter(condition=[OR(=($7, 10), true)])
>     LogicalJoin(condition=[=($7, $9)], joinType=[inner])
>       LogicalTableScan(table=[[CATALOG, SALES, EMP]])
>       LogicalAggregate(group=[{0}])
>         LogicalProject(DEPTNO=[$0])
>           LogicalFilter(condition=[<($0, 5)])
>             LogicalTableScan(table=[[CATALOG, SALES, DEPT]])
> {code}
> But that's not right. {code}LogicalFilter(condition=[OR(=($7, 10), true)]){code} is always true and is in the wrong place anyway (it's applied after the inner join, where all the deptno = 10 records have already been removed).



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)