Thanks Julian, it is working now, I have updated the ticket accordingly.

On 16 February 2018 at 23:24, Julian Hyde <jh...@apache.org> wrote:

> I have made you a contributor; can you try doing "More > Link” again?
>
>
> > On Feb 16, 2018, at 11:45 AM, Alessandro Solimando <
> alessandro.solima...@gmail.com> wrote:
> >
> > I have just checked and the issue is still there, so here is the ticket:
> > CALCITE-2184 <https://issues.apache.org/jira/browse/CALCITE-2184>
> >
> > It is linked to CALCITE-2183
> > <https://issues.apache.org/jira/browse/CALCITE-2183>, I have tried to
> link
> > it "the nice" way but I have failed, maybe I am missing the rights.
> >
> > It is anyway linked in the body of the ticket and a comment.
> >
> > On 15 February 2018 at 19:31, Julian Hyde <jh...@apache.org> wrote:
> >
> >> If this still occurs in the latest master then yes, definitely log a
> JIRA
> >> case.
> >>
> >> On Wed, Feb 14, 2018 at 3:41 PM, Alessandro Solimando
> >> <alessandro.solima...@gmail.com> wrote:
> >>> Hello,
> >>> while executing this query Calcite tries to cast the subquery
> >> (RexSubQuery)
> >>> to a local reference (RexLocalRef), resulting in a ClassCastException.
> >>>
> >>> Here is the query:
> >>>
> >>>>
> >>>> *select **
> >>>> *from (values (1, 'a'), (2, 'b'), (3, 'b'), (4, 'c'), (2, 'c')) as
> t(x,
> >> y)*
> >>>> *where exists (*
> >>>> *  select **
> >>>> *  from (values (1, 'a'), (2, 'b')) as v(w, z)*
> >>>> *  where w < x**)*
> >>>
> >>>
> >>> But the same happens with other (similar) queries:
> >>>
> >>>> *select x*
> >>>
> >>> *from (values (1, 'a'), (2, 'b')) as t(x, y)*
> >>>
> >>> *where x <= all (*
> >>>
> >>> *  select x*
> >>>
> >>> *  from (values (1, 'a'), (2, 'b'), (1, 'b'), (2, 'c'), (2, 'c')) as
> t(x,
> >>>> y)*
> >>>
> >>> *)*
> >>>
> >>>
> >>> Can you confirm the issue?
> >>> If so I will open a ticket, so I can mark as ignored the related tests
> >> with
> >>> a reference to such ticket (until the problem gets fixed).
> >>>
> >>> If needed, they can inspected here:
> >>> https://github.com/asolimando/calcite/tree/SPARK-TESTS
> >>>
> >>> The tests reproducing the issue are:
> >>> -) testFilterExists
> >>> -) testFilterNotExists
> >>> -) testSubqueryAny
> >>> -) testSubqueryAll
> >>>
> >>> Below the full stack trace (for the first query mentioned above):
> >>>
> >>> java.lang.RuntimeException: With materializationsEnabled=false, limit=0
> >>>> at
> >>>> org.apache.calcite.test.CalciteAssert.assertQuery(
> >> CalciteAssert.java:600)
> >>>> at
> >>>> org.apache.calcite.test.CalciteAssert$AssertQuery.
> >> returns(CalciteAssert.java:1346)
> >>>> at
> >>>> org.apache.calcite.test.CalciteAssert$AssertQuery.
> >> returns(CalciteAssert.java:1329)
> >>>> at
> >>>> org.apache.calcite.test.CalciteAssert$AssertQuery.returnsUnordered(
> >> CalciteAssert.java:1357)
> >>>> at
> >>>> org.apache.calcite.test.SparkAdapterTest.commonTester(
> >> SparkAdapterTest.java:93)
> >>>> at
> >>>> org.apache.calcite.test.SparkAdapterTest.testFilterExists(
> >> SparkAdapterTest.java:720)
> >>>> 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:47)
> >>>> 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.sql.SQLException: Error while executing SQL "select *
> >>>> from (values (1, 'a'), (2, 'b'), (3, 'b'), (4, 'c'), (2, 'c')) as t(x,
> >> y)
> >>>> where exists (
> >>>>  select *
> >>>>  from (values (1, 'a'), (2, 'b')) as v(w, z)
> >>>>  where w < x
> >>>> )": org.apache.calcite.rex.RexSubQuery cannot be cast to
> >>>> org.apache.calcite.rex.RexLocalRef
> >>>> at org.apache.calcite.avatica.Helper.createException(Helper.java:56)
> >>>> at org.apache.calcite.avatica.Helper.createException(Helper.java:41)
> >>>> at
> >>>> org.apache.calcite.avatica.AvaticaStatement.executeInternal(
> >> AvaticaStatement.java:156)
> >>>> at
> >>>> org.apache.calcite.avatica.AvaticaStatement.executeQuery(
> >> AvaticaStatement.java:218)
> >>>> at
> >>>> org.apache.calcite.test.CalciteAssert.assertQuery(
> >> CalciteAssert.java:568)
> >>>> ... 27 more
> >>>> Caused by: java.lang.ClassCastException:
> >>>> org.apache.calcite.rex.RexSubQuery cannot be cast to
> >>>> org.apache.calcite.rex.RexLocalRef
> >>>> at
> >>>> org.apache.calcite.rex.RexProgramBuilder.registerInput(
> >> RexProgramBuilder.java:298)
> >>>> at
> >>>> org.apache.calcite.rex.RexProgramBuilder.addCondition(
> >> RexProgramBuilder.java:272)
> >>>> at
> >>>> org.apache.calcite.adapter.enumerable.EnumerableFilterToCalcRule.
> >> onMatch(EnumerableFilterToCalcRule.java:50)
> >>>> at
> >>>> org.apache.calcite.plan.AbstractRelOptPlanner.fireRule(
> >> AbstractRelOptPlanner.java:317)
> >>>> at org.apache.calcite.plan.hep.HepPlanner.applyRule(
> >> HepPlanner.java:555)
> >>>> at org.apache.calcite.plan.hep.HepPlanner.applyRules(
> >> HepPlanner.java:415)
> >>>> at
> >>>> org.apache.calcite.plan.hep.HepPlanner.executeInstruction(
> >> HepPlanner.java:252)
> >>>> at
> >>>> org.apache.calcite.plan.hep.HepInstruction$RuleInstance.
> >> execute(HepInstruction.java:127)
> >>>> at
> >>>> org.apache.calcite.plan.hep.HepPlanner.executeProgram(
> >> HepPlanner.java:211)
> >>>> at org.apache.calcite.plan.hep.HepPlanner.findBestExp(
> >> HepPlanner.java:198)
> >>>> at org.apache.calcite.tools.Programs$2.run(Programs.java:213)
> >>>> at org.apache.calcite.tools.Programs$SequenceProgram.run(
> >> Programs.java:387)
> >>>> at org.apache.calcite.prepare.Prepare.optimize(Prepare.java:188)
> >>>> at org.apache.calcite.prepare.Prepare.prepareSql(Prepare.java:319)
> >>>> at org.apache.calcite.prepare.Prepare.prepareSql(Prepare.java:230)
> >>>> at
> >>>> org.apache.calcite.prepare.CalcitePrepareImpl.prepare2_(
> >> CalcitePrepareImpl.java:781)
> >>>> at
> >>>> org.apache.calcite.prepare.CalcitePrepareImpl.prepare_(
> >> CalcitePrepareImpl.java:640)
> >>>> at
> >>>> org.apache.calcite.prepare.CalcitePrepareImpl.prepareSql(
> >> CalcitePrepareImpl.java:610)
> >>>> at
> >>>> org.apache.calcite.jdbc.CalciteConnectionImpl.parseQuery(
> >> CalciteConnectionImpl.java:221)
> >>>> at
> >>>> org.apache.calcite.jdbc.CalciteMetaImpl.prepareAndExecute(
> >> CalciteMetaImpl.java:603)
> >>>> at
> >>>> org.apache.calcite.avatica.AvaticaConnection.
> prepareAndExecuteInternal(
> >> AvaticaConnection.java:638)
> >>>> at
> >>>> org.apache.calcite.avatica.AvaticaStatement.executeInternal(
> >> AvaticaStatement.java:149)
> >>>> ... 29 more
> >>>> java.lang.RuntimeException: exception while executing [select *
> >>>> from (values (1, 'a'), (2, 'b'), (3, 'b'), (4, 'c'), (2, 'c')) as t(x,
> >> y)
> >>>> where exists (
> >>>>  select *
> >>>>  from (values (1, 'a'), (2, 'b')) as v(w, z)
> >>>>  where w < x
> >>>> )]
> >>>> at
> >>>> org.apache.calcite.test.CalciteAssert$AssertQuery.
> >> returns(CalciteAssert.java:1351)
> >>>> at
> >>>> org.apache.calcite.test.CalciteAssert$AssertQuery.
> >> returns(CalciteAssert.java:1329)
> >>>> at
> >>>> org.apache.calcite.test.CalciteAssert$AssertQuery.returnsUnordered(
> >> CalciteAssert.java:1357)
> >>>> at
> >>>> org.apache.calcite.test.SparkAdapterTest.commonTester(
> >> SparkAdapterTest.java:93)
> >>>> at
> >>>> org.apache.calcite.test.SparkAdapterTest.testFilterExists(
> >> SparkAdapterTest.java:720)
> >>>> 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:47)
> >>>> at
> >>>> com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(
> >> JUnitStarter.java:242)
> >>>> at com.intellij.rt.execution.junit.JUnitStarter.main(
> >> JUnitStarter.java:70)
> >>>
> >>>
> >>> Best regards,
> >>> Alessandro
> >>
>
>

Reply via email to