[jira] [Updated] (CALCITE-2184) subquery leading to a "java.lang.ClassCastException: RexSubQuery cannot be cast to RexLocalRef"

2018-03-11 Thread Alessandro Solimando (JIRA)

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

Alessandro Solimando updated CALCITE-2184:
--
Priority: Minor  (was: Major)

> subquery leading to a "java.lang.ClassCastException: RexSubQuery cannot be 
> cast to RexLocalRef"
> ---
>
> Key: CALCITE-2184
> URL: https://issues.apache.org/jira/browse/CALCITE-2184
> Project: Calcite
>  Issue Type: Bug
>  Components: core
>Affects Versions: 1.16.0
>Reporter: Alessandro Solimando
>Assignee: Julian Hyde
>Priority: Minor
>
> Executing this query Calcite tries to cast the subquery (_RexSubQuery_) to a 
> local reference (_RexLocalRef_), resulting in a _ClassCastException_.
> Here is the query: 
> {code: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
> )
> {code}
> But the same happens with other (similar) queries, such as the following:
> {code:sql}
> 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)
> )
> {code}
> Please note that this problem is "masked" by the issues described in 
> [CALCITE-2183|https://issues.apache.org/jira/browse/CALCITE-2183], and it can 
> be reproduced only by "patching" this second.
> Below the complete stack trace:
> {noformat}
> 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 
> 

[jira] [Updated] (CALCITE-2184) subquery leading to a "java.lang.ClassCastException: RexSubQuery cannot be cast to RexLocalRef"

2018-02-16 Thread Alessandro Solimando (JIRA)

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

Alessandro Solimando updated CALCITE-2184:
--
Priority: Major  (was: Minor)

> subquery leading to a "java.lang.ClassCastException: RexSubQuery cannot be 
> cast to RexLocalRef"
> ---
>
> Key: CALCITE-2184
> URL: https://issues.apache.org/jira/browse/CALCITE-2184
> Project: Calcite
>  Issue Type: Bug
>  Components: core
>Affects Versions: 1.16.0
>Reporter: Alessandro Solimando
>Assignee: Julian Hyde
>Priority: Major
>
> Executing this query Calcite tries to cast the subquery (_RexSubQuery_) to a 
> local reference (_RexLocalRef_), resulting in a _ClassCastException_.
> Here is the query: 
> {code: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
> )
> {code}
> But the same happens with other (similar) queries, such as the following:
> {code:sql}
> 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)
> )
> {code}
> Please note that this problem is "masked" by the issues described in 
> [CALCITE-2183|https://issues.apache.org/jira/browse/CALCITE-2183], and it can 
> be reproduced only by "patching" this second.
> Below the complete stack trace:
> {noformat}
> 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 
> 

[jira] [Updated] (CALCITE-2184) subquery leading to a "java.lang.ClassCastException: RexSubQuery cannot be cast to RexLocalRef"

2018-02-16 Thread Alessandro Solimando (JIRA)

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

Alessandro Solimando updated CALCITE-2184:
--
External issue URL:   (was: 
https://issues.apache.org/jira/browse/CALCITE-2183)
 External issue ID:   (was: CALCITE-2183)

Depends on [CALCITE-2183|https://issues.apache.org/jira/browse/CALCITE-2183]

> subquery leading to a "java.lang.ClassCastException: RexSubQuery cannot be 
> cast to RexLocalRef"
> ---
>
> Key: CALCITE-2184
> URL: https://issues.apache.org/jira/browse/CALCITE-2184
> Project: Calcite
>  Issue Type: Bug
>  Components: core
>Affects Versions: 1.16.0
>Reporter: Alessandro Solimando
>Assignee: Julian Hyde
>Priority: Minor
>
> Executing this query Calcite tries to cast the subquery (_RexSubQuery_) to a 
> local reference (_RexLocalRef_), resulting in a _ClassCastException_.
> Here is the query: 
> {code: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
> )
> {code}
> But the same happens with other (similar) queries, such as the following:
> {code:sql}
> 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)
> )
> {code}
> Please note that this problem is "masked" by the issues described in 
> [CALCITE-2183|https://issues.apache.org/jira/browse/CALCITE-2183], and it can 
> be reproduced only by "patching" this second.
> Below the complete stack trace:
> {noformat}
> 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 
> 

[jira] [Updated] (CALCITE-2184) subquery leading to a "java.lang.ClassCastException: RexSubQuery cannot be cast to RexLocalRef"

2018-02-16 Thread Alessandro Solimando (JIRA)

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

Alessandro Solimando updated CALCITE-2184:
--
External issue URL: https://issues.apache.org/jira/browse/CALCITE-2183
 External issue ID: CALCITE-2183

> subquery leading to a "java.lang.ClassCastException: RexSubQuery cannot be 
> cast to RexLocalRef"
> ---
>
> Key: CALCITE-2184
> URL: https://issues.apache.org/jira/browse/CALCITE-2184
> Project: Calcite
>  Issue Type: Bug
>  Components: core
>Affects Versions: 1.16.0
>Reporter: Alessandro Solimando
>Assignee: Julian Hyde
>Priority: Minor
>
> Executing this query Calcite tries to cast the subquery (_RexSubQuery_) to a 
> local reference (_RexLocalRef_), resulting in a _ClassCastException_.
> Here is the query: 
> {code: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
> )
> {code}
> But the same happens with other (similar) queries, such as the following:
> {code:sql}
> 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)
> )
> {code}
> Please note that this problem is "masked" by the issues described in 
> [CALCITE-2183|https://issues.apache.org/jira/browse/CALCITE-2183], and it can 
> be reproduced only by "patching" this second.
> Below the complete stack trace:
> {noformat}
> 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 
>