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/02/23 17:05:44 UTC

[jira] [Commented] (CALCITE-685) Correlated scalar sub-query in SELECT clause throws

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

Julian Hyde commented on CALCITE-685:
-------------------------------------

Added test case (disabled) in http://git-wip-us.apache.org/repos/asf/calcite/commit/ee289e4f.

> Correlated scalar sub-query in SELECT clause throws
> ---------------------------------------------------
>
>                 Key: CALCITE-685
>                 URL: https://issues.apache.org/jira/browse/CALCITE-685
>             Project: Calcite
>          Issue Type: Bug
>            Reporter: Jinfeng Ni
>            Assignee: Julian Hyde
>              Labels: sub-query
>
> For the following query, where a correlated scalar subquery is put in select list, Calcite will hit NPE in RelDecorrelator.
> {code}
> select e.department_id, sum(e.employee_id),
>        ( select sum(e2.employee_id)
>          from  employee e2
>          where e.department_id = e2.department_id
>        )
> from employee e
> group by e.department_id;
> {code}
> {code}
> Caused by: java.lang.NullPointerException
> 	at org.apache.calcite.sql2rel.RelDecorrelator.createValueGenerator(RelDecorrelator.java:733)
> 	at org.apache.calcite.sql2rel.RelDecorrelator.decorrelateInputWithValueGenerator(RelDecorrelator.java:842)
> 	at org.apache.calcite.sql2rel.RelDecorrelator.decorrelateRel(RelDecorrelator.java:902)
> 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> 	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
> 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
> 	at org.apache.calcite.util.ReflectUtil.invokeVisitorInternal(ReflectUtil.java:256)
> 	at org.apache.calcite.util.ReflectUtil.invokeVisitor(ReflectUtil.java:213)
> 	at org.apache.calcite.util.ReflectUtil$1.invokeVisitor(ReflectUtil.java:476)
> 	at org.apache.calcite.sql2rel.RelDecorrelator$DecorrelateRelVisitor.visit(RelDecorrelator.java:1420)
> 	at org.apache.calcite.rel.SingleRel.childrenAccept(SingleRel.java:72)
> .....
> {code}
> Here is the unit test case I used to re-produce this problem in JdbcTest.java
> {code}
>   @Test public void testCorreScalarSubQInSelect()
>       throws ClassNotFoundException, SQLException {
>     String query = "select e.department_id, sum(e.employee_id),\n"
>         + "       ( select sum(e2.employee_id)\n"
>         + "         from  employee e2\n"
>         + "         where e.department_id = e2.department_id\n"
>         + "       )\n"
>         + " from employee e\n"
>         + " group by e.department_id\n";
>     CalciteAssert.that()
>         .with(CalciteAssert.Config.FOODMART_CLONE)
>         .with(Lex.JAVA)
>         .query(query)
>         .returnsCount(0);
>   }
> {code}



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