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/07/28 22:53:00 UTC

[jira] [Resolved] (CALCITE-1907) Table function with 1 column gives ClassCastException

     [ https://issues.apache.org/jira/browse/CALCITE-1907?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Julian Hyde resolved CALCITE-1907.
----------------------------------
       Resolution: Fixed
    Fix Version/s: 1.14.0

Fixed in  http://git-wip-us.apache.org/repos/asf/calcite/commit/a473eca5.

> Table function with 1 column gives ClassCastException
> -----------------------------------------------------
>
>                 Key: CALCITE-1907
>                 URL: https://issues.apache.org/jira/browse/CALCITE-1907
>             Project: Calcite
>          Issue Type: Bug
>            Reporter: Julian Hyde
>            Assignee: Julian Hyde
>             Fix For: 1.14.0
>
>
> If a table function has 1 column and is used under a Filter or Aggregate, the query gives ClassCastException when executed:
> {noformat}
> java.lang.RuntimeException: exception while executing [select *
> from table("s"."fibonacci"())]
> 	at org.apache.calcite.test.CalciteAssert$AssertQuery.returns(CalciteAssert.java:1270)
> 	at org.apache.calcite.test.CalciteAssert$AssertQuery.returns(CalciteAssert.java:1249)
> 	at org.apache.calcite.test.TableFunctionTest.testUserDefinedTableFunction6(TableFunctionTest.java:381)
> 	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:498)
> 	at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
> 	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
> 	at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
> 	at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
> 	at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
> 	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
> 	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
> 	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
> 	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
> 	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
> 	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
> 	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
> 	at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
> 	at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
> 	at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)
> 	at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:51)
> 	at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)
> 	at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)
> Caused by: java.lang.ClassCastException: [Ljava.lang.Object; cannot be cast to java.lang.Long
> 	at org.apache.calcite.avatica.util.AbstractCursor$LongAccessor.getLong(AbstractCursor.java:550)
> 	at org.apache.calcite.avatica.AvaticaResultSet.getLong(AvaticaResultSet.java:277)
> 	at org.apache.calcite.test.TableFunctionTest$1.apply(TableFunctionTest.java:387)
> 	at org.apache.calcite.test.TableFunctionTest$1.apply(TableFunctionTest.java:382)
> 	at org.apache.calcite.test.CalciteAssert.assertQuery(CalciteAssert.java:533)
> 	at org.apache.calcite.test.CalciteAssert$AssertQuery.returns(CalciteAssert.java:1266)
> {noformat}
> The cause is a slight difference what the enumerable to iterable converter requires (arrays if there is more than one column, scalars is there is 1 column) and the specification of table functions (always return arrays).
> Up until now we have been masking the problem by applying "slice" to the output of table functions. Which is fine if the output goes straight into the JDBC result set, but not fine if there are other operators, such as Filter or Aggregate, downstream.



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)