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 2015/05/01 20:16:07 UTC

[jira] [Created] (CALCITE-709) Errors with LIMIT inside scalar sub-query

Julian Hyde created CALCITE-709:
-----------------------------------

             Summary: Errors with LIMIT inside scalar sub-query
                 Key: CALCITE-709
                 URL: https://issues.apache.org/jira/browse/CALCITE-709
             Project: Calcite
          Issue Type: Bug
            Reporter: Julian Hyde
            Assignee: Julian Hyde


Various when you use LIMIT inside a scalar sub-query.

Error 1:

{code}select deptno, (select empno 
    from "scott".emp
    where deptno = dept.deptno
    order by empno limit 1) as x
from "scott".dept;{code}

gives {code}java.sql.SQLException: error while executing SQL "select deptno, (select empno from "scott".emp where deptno = dept.deptno order by empno limit 1) as x from "scott".dept
": Error while compiling generated Java code:
Caused by: org.codehaus.commons.compiler.CompileException: Line 65, Column 49: Not a boolean expression{code}

Error 2:

{code}select deptno, (select sum(empno)
    from "scott".emp
    where deptno = dept.deptno
    limit 0) as x
from "scott".dept;{code}

gives {code}java.sql.SQLException: error while executing SQL "select deptno, (select sum(empno) from "scott".emp where deptno = dept.deptno limit 0) as x from "scott".dept
Target must be less than target count, 2
	at org.apache.calcite.avatica.Helper.createException(Helper.java:41)
	at org.apache.calcite.avatica.AvaticaStatement.executeInternal(AvaticaStatement.java:112)
	at org.apache.calcite.avatica.AvaticaStatement.executeQuery(AvaticaStatement.java:130)
	at net.hydromatic.quidem.Quidem$CheckResultCommand.execute(Quidem.java:690)
	at net.hydromatic.quidem.Quidem$CompositeCommand.execute(Quidem.java:926)
	at net.hydromatic.quidem.Quidem.execute(Quidem.java:193)
	at org.apache.calcite.test.JdbcTest.checkRun(JdbcTest.java:4402)
	at org.apache.calcite.test.JdbcTest.testRunScalar(JdbcTest.java:4370)
Caused by: java.lang.IllegalArgumentException: Target must be less than target count, 2
	at org.apache.calcite.util.mapping.Mappings$PartialFunctionImpl.set(Mappings.java:1607)
	at org.apache.calcite.util.mapping.Mappings.target(Mappings.java:323)
	at org.apache.calcite.sql2rel.RelDecorrelator.decorrelateRel(RelDecorrelator.java:401)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:497)
	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:1421)
	at org.apache.calcite.rel.BiRel.childrenAccept(BiRel.java:47){code}

The test cases are included in scalar.oq, commented out usind '!if (false) { ... }'; you can run via JdbcTest.testRunScalar.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)