Details
-
Bug
-
Status: In Progress
-
Major
-
Resolution: Unresolved
-
None
-
None
-
None
Description
Various when you use LIMIT inside a scalar sub-query.
Error 1:
select deptno, (select empno from "scott".emp where deptno = dept.deptno order by empno limit 1) as x from "scott".dept;
gives
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
Error 2:
select deptno, (select sum(empno) from "scott".emp where deptno = dept.deptno limit 0) as x from "scott".dept;
gives
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)
The test cases are included in scalar.oq, commented out usind '!if (false) ...'; you can run via JdbcTest.testRunScalar.
Attachments
Issue Links
- depends upon
-
CALCITE-1045 Decorrelate sub-queries in Project and Join
- Reopened
- is related to
-
CALCITE-816 Represent sub-query as a RexNode
- Closed