I don't think we implement INTERSECT ALL or EXCEPT ALL; only UNION
ALL. I modified JdbcFrontLinqBackTest.testIntersect() and got a
similar problem.

See https://issues.apache.org/jira/browse/CALCITE-1446.

On Fri, Feb 9, 2018 at 2:17 PM, Alessandro Solimando
<alessandro.solima...@gmail.com> wrote:
> Hello,
> I am currently extending the unit tests for SparkAdapter.
>
> The following query raises an exception from the query planner, who fails to
> come up with a plan (getBestPlan call is null).
>
>>
>> select *
>>
>> from (values (1, 'a'), (2, 'b')) as t(x, y)
>>
>>
>>
>> intersect all
>>
>>
>>
>> select *
>> from (values (1, 'a'), (2, 'b'), (1, 'b'), (2, 'c'), (2, 'c')) as t(x, y)
>
>
> Note that the exact same query *without* "all" works fine.
>
> If you want to have a quick look here is my branch:
> https://github.com/asolimando/calcite/tree/SPARK-TESTS
>
> I have started to compare the two executions by tracing which rules are
> matching and which (equivalent) relations they generate, and there are
> several rules not matched for "interesect all" case, compared to
> "intersect", as you can see from the two traces in attachment.
>
> Depending on the kind of rules this might make sense, as the two queries
> differ for duplicate values, and this might prevent some rules to trigger.
>
> I am still getting acquainted with Calcite's internals, so before digging
> too much I preferred to get back to you for:
>
> 1) Does this relate to any known issue, or should I open a JIRA ticket?
> 2) Do you have any suggestion on what to add to the trace?
> At the moment the traces show:
> the current rule tested in OPTIMIZE phase
> TAB content of rule queue
> 2xTAB all the relations for all the existing sets (to understand what is
> created by each rule)
>
> Below the full stacktrace:
>
>>> 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:88)
>>>
>>> at
>>> org.apache.calcite.test.SparkAdapterTest.testIntersectAll(SparkAdapterTest.java:227)
>>>
>>> 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')) as t(x, y)
>>>
>>>  intersect all
>>>
>>> select *
>>>
>>> from (values (1, 'a'), (2, 'b'), (1, 'b'), (2, 'c'), (2, 'c')) as t(x,
>>> y)": Node [rel#18:Subset#4.ENUMERABLE.[]] could not be implemented; planner
>>> state:
>>>
>>>
>>> Root: rel#18:Subset#4.ENUMERABLE.[]
>>>
>>> Original rel:
>>>
>>> LogicalIntersect(subset=[rel#18:Subset#4.ENUMERABLE.[]], all=[true]):
>>> rowcount = 2.0, cumulative cost = {2.0 rows, 2.0 cpu, 0.0 io}, id = 13
>>>
>>>   LogicalProject(subset=[rel#9:Subset#1.NONE.[]], X=[$0], Y=[$1]):
>>> rowcount = 2.0, cumulative cost = {2.0 rows, 4.0 cpu, 0.0 io}, id = 8
>>>
>>>     LogicalValues(subset=[rel#7:Subset#0.NONE.[]], tuples=[[{ 1, 'a' }, {
>>> 2, 'b' }]]): rowcount = 2.0, cumulative cost = {2.0 rows, 1.0 cpu, 0.0 io},
>>> id = 1
>>>
>>>   LogicalProject(subset=[rel#12:Subset#3.NONE.[1]], X=[$0], Y=[$1]):
>>> rowcount = 5.0, cumulative cost = {5.0 rows, 10.0 cpu, 0.0 io}, id = 11
>>>
>>>     LogicalValues(subset=[rel#10:Subset#2.NONE.[1]], tuples=[[{ 1, 'a' },
>>> { 2, 'b' }, { 1, 'b' }, { 2, 'c' }, { 2, 'c' }]]): rowcount = 5.0,
>>> cumulative cost = {5.0 rows, 1.0 cpu, 0.0 io}, id = 4
>>>
>>>
>>> Sets:
>>>
>>> Set#0, type: RecordType(INTEGER X, CHAR(1) Y)
>>>
>>> rel#7:Subset#0.NONE.[], best=null, importance=0.81
>>>
>>> rel#1:LogicalValues.NONE.[[0, 1], [1]](type=RecordType(INTEGER X, CHAR(1)
>>> Y),tuples=[{ 1, 'a' }, { 2, 'b' }]), rowcount=2.0, cumulative cost={inf}
>>>
>>> rel#8:LogicalProject.NONE.[[0, 1],
>>> [1]](input=rel#7:Subset#0.NONE.[],X=$0,Y=$1), rowcount=2.0, cumulative
>>> cost={inf}
>>>
>>> rel#21:Subset#0.ENUMERABLE.[], best=rel#25, importance=0.4510687500000001
>>>
>>>
>>> rel#22:EnumerableProject.ENUMERABLE.[](input=rel#21:Subset#0.ENUMERABLE.[],X=$0,Y=$1),
>>> rowcount=2.0, cumulative cost={4.0 rows, 5.0 cpu, 0.0 io}
>>>
>>> rel#25:EnumerableValues.ENUMERABLE.[[0, 1], [1]](type=RecordType(INTEGER
>>> X, CHAR(1) Y),tuples=[{ 1, 'a' }, { 2, 'b' }]), rowcount=2.0, cumulative
>>> cost={2.0 rows, 1.0 cpu, 0.0 io}
>>>
>>> Set#2, type: RecordType(INTEGER X, CHAR(1) Y)
>>>
>>> rel#10:Subset#2.NONE.[1], best=null, importance=0.81
>>>
>>> rel#4:LogicalValues.NONE.[[1]](type=RecordType(INTEGER X, CHAR(1)
>>> Y),tuples=[{ 1, 'a' }, { 2, 'b' }, { 1, 'b' }, { 2, 'c' }, { 2, 'c' }]),
>>> rowcount=5.0, cumulative cost={inf}
>>>
>>>
>>> rel#11:LogicalProject.NONE.[[1]](input=rel#10:Subset#2.NONE.[1],X=$0,Y=$1),
>>> rowcount=5.0, cumulative cost={inf}
>>>
>>> rel#24:Subset#2.ENUMERABLE.[1], best=rel#23,
>>> importance=0.4510687500000001
>>>
>>> rel#23:EnumerableValues.ENUMERABLE.[[1]](type=RecordType(INTEGER X,
>>> CHAR(1) Y),tuples=[{ 1, 'a' }, { 2, 'b' }, { 1, 'b' }, { 2, 'c' }, { 2, 'c'
>>> }]), rowcount=5.0, cumulative cost={5.0 rows, 1.0 cpu, 0.0 io}
>>>
>>>
>>> rel#26:EnumerableProject.ENUMERABLE.[[1]](input=rel#24:Subset#2.ENUMERABLE.[1],X=$0,Y=$1),
>>> rowcount=5.0, cumulative cost={10.0 rows, 11.0 cpu, 0.0 io}
>>>
>>> Set#4, type: RecordType(INTEGER X, CHAR(1) Y)
>>>
>>> rel#14:Subset#4.NONE.[], best=null, importance=0.9
>>>
>>>
>>> rel#13:LogicalIntersect.NONE.[](input#0=rel#7:Subset#0.NONE.[],input#1=rel#10:Subset#2.NONE.[1],all=true),
>>> rowcount=2.0, cumulative cost={inf}
>>>
>>>
>>> rel#17:AbstractConverter.NONE.[](input=rel#15:Subset#4.SPARK.[],convention=NONE,sort=[]),
>>> rowcount=2.0, cumulative cost={inf}
>>>
>>> rel#15:Subset#4.SPARK.[], best=null, importance=0.81
>>>
>>> rel#18:Subset#4.ENUMERABLE.[], best=null, importance=1.0
>>>
>>>
>>> rel#19:AbstractConverter.ENUMERABLE.[](input=rel#14:Subset#4.NONE.[],convention=ENUMERABLE,sort=[]),
>>> rowcount=2.0, cumulative cost={inf}
>>>
>>>
>>> rel#20:AbstractConverter.ENUMERABLE.[](input=rel#15:Subset#4.SPARK.[],convention=ENUMERABLE,sort=[]),
>>> rowcount=2.0, cumulative cost={inf}
>>>
>>>
>>>
>>> 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: org.apache.calcite.plan.RelOptPlanner$CannotPlanException:
>>> Node [rel#18:Subset#4.ENUMERABLE.[]] could not be implemented; planner
>>> state:
>>>
>>>
>>> Root: rel#18:Subset#4.ENUMERABLE.[]
>>>
>>> Original rel:
>>>
>>> LogicalIntersect(subset=[rel#18:Subset#4.ENUMERABLE.[]], all=[true]):
>>> rowcount = 2.0, cumulative cost = {2.0 rows, 2.0 cpu, 0.0 io}, id = 13
>>>
>>>   LogicalProject(subset=[rel#9:Subset#1.NONE.[]], X=[$0], Y=[$1]):
>>> rowcount = 2.0, cumulative cost = {2.0 rows, 4.0 cpu, 0.0 io}, id = 8
>>>
>>>     LogicalValues(subset=[rel#7:Subset#0.NONE.[]], tuples=[[{ 1, 'a' }, {
>>> 2, 'b' }]]): rowcount = 2.0, cumulative cost = {2.0 rows, 1.0 cpu, 0.0 io},
>>> id = 1
>>>
>>>   LogicalProject(subset=[rel#12:Subset#3.NONE.[1]], X=[$0], Y=[$1]):
>>> rowcount = 5.0, cumulative cost = {5.0 rows, 10.0 cpu, 0.0 io}, id = 11
>>>
>>>     LogicalValues(subset=[rel#10:Subset#2.NONE.[1]], tuples=[[{ 1, 'a' },
>>> { 2, 'b' }, { 1, 'b' }, { 2, 'c' }, { 2, 'c' }]]): rowcount = 5.0,
>>> cumulative cost = {5.0 rows, 1.0 cpu, 0.0 io}, id = 4
>>>
>>>
>>> Sets:
>>>
>>> Set#0, type: RecordType(INTEGER X, CHAR(1) Y)
>>>
>>> rel#7:Subset#0.NONE.[], best=null, importance=0.81
>>>
>>> rel#1:LogicalValues.NONE.[[0, 1], [1]](type=RecordType(INTEGER X, CHAR(1)
>>> Y),tuples=[{ 1, 'a' }, { 2, 'b' }]), rowcount=2.0, cumulative cost={inf}
>>>
>>> rel#8:LogicalProject.NONE.[[0, 1],
>>> [1]](input=rel#7:Subset#0.NONE.[],X=$0,Y=$1), rowcount=2.0, cumulative
>>> cost={inf}
>>>
>>> rel#21:Subset#0.ENUMERABLE.[], best=rel#25, importance=0.4510687500000001
>>>
>>>
>>> rel#22:EnumerableProject.ENUMERABLE.[](input=rel#21:Subset#0.ENUMERABLE.[],X=$0,Y=$1),
>>> rowcount=2.0, cumulative cost={4.0 rows, 5.0 cpu, 0.0 io}
>>>
>>> rel#25:EnumerableValues.ENUMERABLE.[[0, 1], [1]](type=RecordType(INTEGER
>>> X, CHAR(1) Y),tuples=[{ 1, 'a' }, { 2, 'b' }]), rowcount=2.0, cumulative
>>> cost={2.0 rows, 1.0 cpu, 0.0 io}
>>>
>>> Set#2, type: RecordType(INTEGER X, CHAR(1) Y)
>>>
>>> rel#10:Subset#2.NONE.[1], best=null, importance=0.81
>>>
>>> rel#4:LogicalValues.NONE.[[1]](type=RecordType(INTEGER X, CHAR(1)
>>> Y),tuples=[{ 1, 'a' }, { 2, 'b' }, { 1, 'b' }, { 2, 'c' }, { 2, 'c' }]),
>>> rowcount=5.0, cumulative cost={inf}
>>>
>>>
>>> rel#11:LogicalProject.NONE.[[1]](input=rel#10:Subset#2.NONE.[1],X=$0,Y=$1),
>>> rowcount=5.0, cumulative cost={inf}
>>>
>>> rel#24:Subset#2.ENUMERABLE.[1], best=rel#23,
>>> importance=0.4510687500000001
>>>
>>> rel#23:EnumerableValues.ENUMERABLE.[[1]](type=RecordType(INTEGER X,
>>> CHAR(1) Y),tuples=[{ 1, 'a' }, { 2, 'b' }, { 1, 'b' }, { 2, 'c' }, { 2, 'c'
>>> }]), rowcount=5.0, cumulative cost={5.0 rows, 1.0 cpu, 0.0 io}
>>>
>>>
>>> rel#26:EnumerableProject.ENUMERABLE.[[1]](input=rel#24:Subset#2.ENUMERABLE.[1],X=$0,Y=$1),
>>> rowcount=5.0, cumulative cost={10.0 rows, 11.0 cpu, 0.0 io}
>>>
>>> Set#4, type: RecordType(INTEGER X, CHAR(1) Y)
>>>
>>> rel#14:Subset#4.NONE.[], best=null, importance=0.9
>>>
>>>
>>> rel#13:LogicalIntersect.NONE.[](input#0=rel#7:Subset#0.NONE.[],input#1=rel#10:Subset#2.NONE.[1],all=true),
>>> rowcount=2.0, cumulative cost={inf}
>>>
>>>
>>> rel#17:AbstractConverter.NONE.[](input=rel#15:Subset#4.SPARK.[],convention=NONE,sort=[]),
>>> rowcount=2.0, cumulative cost={inf}
>>>
>>> rel#15:Subset#4.SPARK.[], best=null, importance=0.81
>>>
>>> rel#18:Subset#4.ENUMERABLE.[], best=null, importance=1.0
>>>
>>>
>>> rel#19:AbstractConverter.ENUMERABLE.[](input=rel#14:Subset#4.NONE.[],convention=ENUMERABLE,sort=[]),
>>> rowcount=2.0, cumulative cost={inf}
>>>
>>>
>>> rel#20:AbstractConverter.ENUMERABLE.[](input=rel#15:Subset#4.SPARK.[],convention=ENUMERABLE,sort=[]),
>>> rowcount=2.0, cumulative cost={inf}
>>>
>>>
>>>
>>> at
>>> org.apache.calcite.plan.volcano.RelSubset$CheapestPlanReplacer.visit(RelSubset.java:441)
>>>
>>> at
>>> org.apache.calcite.plan.volcano.RelSubset.buildCheapestPlan(RelSubset.java:291)
>>>
>>> at
>>> org.apache.calcite.plan.volcano.VolcanoPlanner.findBestExp(VolcanoPlanner.java:666)
>>>
>>> at org.apache.calcite.tools.Programs$5.run(Programs.java:326)
>>>
>>> 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')) as t(x, y)
>>>
>>>  intersect all
>>>
>>> select *
>>>
>>> from (values (1, 'a'), (2, 'b'), (1, 'b'), (2, 'c'), (2, 'c')) as t(x,
>>> y)]
>>>
>>>
>>> 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:88)
>>>
>>> at
>>> org.apache.calcite.test.SparkAdapterTest.testIntersectAll(SparkAdapterTest.java:227)
>>>
>>> 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.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)
>>>
>>> ... 26 more
>>>
>>> Caused by: java.sql.SQLException: Error while executing SQL "select *
>>>
>>> from (values (1, 'a'), (2, 'b')) as t(x, y)
>>>
>>>  intersect all
>>>
>>> select *
>>>
>>> from (values (1, 'a'), (2, 'b'), (1, 'b'), (2, 'c'), (2, 'c')) as t(x,
>>> y)": Node [rel#18:Subset#4.ENUMERABLE.[]] could not be implemented; planner
>>> state:
>>>
>>>
>>> Root: rel#18:Subset#4.ENUMERABLE.[]
>>>
>>> Original rel:
>>>
>>> LogicalIntersect(subset=[rel#18:Subset#4.ENUMERABLE.[]], all=[true]):
>>> rowcount = 2.0, cumulative cost = {2.0 rows, 2.0 cpu, 0.0 io}, id = 13
>>>
>>>   LogicalProject(subset=[rel#9:Subset#1.NONE.[]], X=[$0], Y=[$1]):
>>> rowcount = 2.0, cumulative cost = {2.0 rows, 4.0 cpu, 0.0 io}, id = 8
>>>
>>>     LogicalValues(subset=[rel#7:Subset#0.NONE.[]], tuples=[[{ 1, 'a' }, {
>>> 2, 'b' }]]): rowcount = 2.0, cumulative cost = {2.0 rows, 1.0 cpu, 0.0 io},
>>> id = 1
>>>
>>>   LogicalProject(subset=[rel#12:Subset#3.NONE.[1]], X=[$0], Y=[$1]):
>>> rowcount = 5.0, cumulative cost = {5.0 rows, 10.0 cpu, 0.0 io}, id = 11
>>>
>>>     LogicalValues(subset=[rel#10:Subset#2.NONE.[1]], tuples=[[{ 1, 'a' },
>>> { 2, 'b' }, { 1, 'b' }, { 2, 'c' }, { 2, 'c' }]]): rowcount = 5.0,
>>> cumulative cost = {5.0 rows, 1.0 cpu, 0.0 io}, id = 4
>>>
>>>
>>> Sets:
>>>
>>> Set#0, type: RecordType(INTEGER X, CHAR(1) Y)
>>>
>>> rel#7:Subset#0.NONE.[], best=null, importance=0.81
>>>
>>> rel#1:LogicalValues.NONE.[[0, 1], [1]](type=RecordType(INTEGER X, CHAR(1)
>>> Y),tuples=[{ 1, 'a' }, { 2, 'b' }]), rowcount=2.0, cumulative cost={inf}
>>>
>>> rel#8:LogicalProject.NONE.[[0, 1],
>>> [1]](input=rel#7:Subset#0.NONE.[],X=$0,Y=$1), rowcount=2.0, cumulative
>>> cost={inf}
>>>
>>> rel#21:Subset#0.ENUMERABLE.[], best=rel#25, importance=0.4510687500000001
>>>
>>>
>>> rel#22:EnumerableProject.ENUMERABLE.[](input=rel#21:Subset#0.ENUMERABLE.[],X=$0,Y=$1),
>>> rowcount=2.0, cumulative cost={4.0 rows, 5.0 cpu, 0.0 io}
>>>
>>> rel#25:EnumerableValues.ENUMERABLE.[[0, 1], [1]](type=RecordType(INTEGER
>>> X, CHAR(1) Y),tuples=[{ 1, 'a' }, { 2, 'b' }]), rowcount=2.0, cumulative
>>> cost={2.0 rows, 1.0 cpu, 0.0 io}
>>>
>>> Set#2, type: RecordType(INTEGER X, CHAR(1) Y)
>>>
>>> rel#10:Subset#2.NONE.[1], best=null, importance=0.81
>>>
>>> rel#4:LogicalValues.NONE.[[1]](type=RecordType(INTEGER X, CHAR(1)
>>> Y),tuples=[{ 1, 'a' }, { 2, 'b' }, { 1, 'b' }, { 2, 'c' }, { 2, 'c' }]),
>>> rowcount=5.0, cumulative cost={inf}
>>>
>>>
>>> rel#11:LogicalProject.NONE.[[1]](input=rel#10:Subset#2.NONE.[1],X=$0,Y=$1),
>>> rowcount=5.0, cumulative cost={inf}
>>>
>>> rel#24:Subset#2.ENUMERABLE.[1], best=rel#23,
>>> importance=0.4510687500000001
>>>
>>> rel#23:EnumerableValues.ENUMERABLE.[[1]](type=RecordType(INTEGER X,
>>> CHAR(1) Y),tuples=[{ 1, 'a' }, { 2, 'b' }, { 1, 'b' }, { 2, 'c' }, { 2, 'c'
>>> }]), rowcount=5.0, cumulative cost={5.0 rows, 1.0 cpu, 0.0 io}
>>>
>>>
>>> rel#26:EnumerableProject.ENUMERABLE.[[1]](input=rel#24:Subset#2.ENUMERABLE.[1],X=$0,Y=$1),
>>> rowcount=5.0, cumulative cost={10.0 rows, 11.0 cpu, 0.0 io}
>>>
>>> Set#4, type: RecordType(INTEGER X, CHAR(1) Y)
>>>
>>> rel#14:Subset#4.NONE.[], best=null, importance=0.9
>>>
>>>
>>> rel#13:LogicalIntersect.NONE.[](input#0=rel#7:Subset#0.NONE.[],input#1=rel#10:Subset#2.NONE.[1],all=true),
>>> rowcount=2.0, cumulative cost={inf}
>>>
>>>
>>> rel#17:AbstractConverter.NONE.[](input=rel#15:Subset#4.SPARK.[],convention=NONE,sort=[]),
>>> rowcount=2.0, cumulative cost={inf}
>>>
>>> rel#15:Subset#4.SPARK.[], best=null, importance=0.81
>>>
>>> rel#18:Subset#4.ENUMERABLE.[], best=null, importance=1.0
>>>
>>>
>>> rel#19:AbstractConverter.ENUMERABLE.[](input=rel#14:Subset#4.NONE.[],convention=ENUMERABLE,sort=[]),
>>> rowcount=2.0, cumulative cost={inf}
>>>
>>>
>>> rel#20:AbstractConverter.ENUMERABLE.[](input=rel#15:Subset#4.SPARK.[],convention=ENUMERABLE,sort=[]),
>>> rowcount=2.0, cumulative cost={inf}
>>>
>>>
>>>
>>> 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: org.apache.calcite.plan.RelOptPlanner$CannotPlanException:
>>> Node [rel#18:Subset#4.ENUMERABLE.[]] could not be implemented; planner
>>> state:
>>>
>>>
>>> Root: rel#18:Subset#4.ENUMERABLE.[]
>>>
>>> Original rel:
>>>
>>> LogicalIntersect(subset=[rel#18:Subset#4.ENUMERABLE.[]], all=[true]):
>>> rowcount = 2.0, cumulative cost = {2.0 rows, 2.0 cpu, 0.0 io}, id = 13
>>>
>>>   LogicalProject(subset=[rel#9:Subset#1.NONE.[]], X=[$0], Y=[$1]):
>>> rowcount = 2.0, cumulative cost = {2.0 rows, 4.0 cpu, 0.0 io}, id = 8
>>>
>>>     LogicalValues(subset=[rel#7:Subset#0.NONE.[]], tuples=[[{ 1, 'a' }, {
>>> 2, 'b' }]]): rowcount = 2.0, cumulative cost = {2.0 rows, 1.0 cpu, 0.0 io},
>>> id = 1
>>>
>>>   LogicalProject(subset=[rel#12:Subset#3.NONE.[1]], X=[$0], Y=[$1]):
>>> rowcount = 5.0, cumulative cost = {5.0 rows, 10.0 cpu, 0.0 io}, id = 11
>>>
>>>     LogicalValues(subset=[rel#10:Subset#2.NONE.[1]], tuples=[[{ 1, 'a' },
>>> { 2, 'b' }, { 1, 'b' }, { 2, 'c' }, { 2, 'c' }]]): rowcount = 5.0,
>>> cumulative cost = {5.0 rows, 1.0 cpu, 0.0 io}, id = 4
>>>
>>>
>>> Sets:
>>>
>>> Set#0, type: RecordType(INTEGER X, CHAR(1) Y)
>>>
>>> rel#7:Subset#0.NONE.[], best=null, importance=0.81
>>>
>>> rel#1:LogicalValues.NONE.[[0, 1], [1]](type=RecordType(INTEGER X, CHAR(1)
>>> Y),tuples=[{ 1, 'a' }, { 2, 'b' }]), rowcount=2.0, cumulative cost={inf}
>>>
>>> rel#8:LogicalProject.NONE.[[0, 1],
>>> [1]](input=rel#7:Subset#0.NONE.[],X=$0,Y=$1), rowcount=2.0, cumulative
>>> cost={inf}
>>>
>>> rel#21:Subset#0.ENUMERABLE.[], best=rel#25, importance=0.4510687500000001
>>>
>>>
>>> rel#22:EnumerableProject.ENUMERABLE.[](input=rel#21:Subset#0.ENUMERABLE.[],X=$0,Y=$1),
>>> rowcount=2.0, cumulative cost={4.0 rows, 5.0 cpu, 0.0 io}
>>>
>>> rel#25:EnumerableValues.ENUMERABLE.[[0, 1], [1]](type=RecordType(INTEGER
>>> X, CHAR(1) Y),tuples=[{ 1, 'a' }, { 2, 'b' }]), rowcount=2.0, cumulative
>>> cost={2.0 rows, 1.0 cpu, 0.0 io}
>>>
>>> Set#2, type: RecordType(INTEGER X, CHAR(1) Y)
>>>
>>> rel#10:Subset#2.NONE.[1], best=null, importance=0.81
>>>
>>> rel#4:LogicalValues.NONE.[[1]](type=RecordType(INTEGER X, CHAR(1)
>>> Y),tuples=[{ 1, 'a' }, { 2, 'b' }, { 1, 'b' }, { 2, 'c' }, { 2, 'c' }]),
>>> rowcount=5.0, cumulative cost={inf}
>>>
>>>
>>> rel#11:LogicalProject.NONE.[[1]](input=rel#10:Subset#2.NONE.[1],X=$0,Y=$1),
>>> rowcount=5.0, cumulative cost={inf}
>>>
>>> rel#24:Subset#2.ENUMERABLE.[1], best=rel#23,
>>> importance=0.4510687500000001
>>>
>>> rel#23:EnumerableValues.ENUMERABLE.[[1]](type=RecordType(INTEGER X,
>>> CHAR(1) Y),tuples=[{ 1, 'a' }, { 2, 'b' }, { 1, 'b' }, { 2, 'c' }, { 2, 'c'
>>> }]), rowcount=5.0, cumulative cost={5.0 rows, 1.0 cpu, 0.0 io}
>>>
>>>
>>> rel#26:EnumerableProject.ENUMERABLE.[[1]](input=rel#24:Subset#2.ENUMERABLE.[1],X=$0,Y=$1),
>>> rowcount=5.0, cumulative cost={10.0 rows, 11.0 cpu, 0.0 io}
>>>
>>> Set#4, type: RecordType(INTEGER X, CHAR(1) Y)
>>>
>>> rel#14:Subset#4.NONE.[], best=null, importance=0.9
>>>
>>>
>>> rel#13:LogicalIntersect.NONE.[](input#0=rel#7:Subset#0.NONE.[],input#1=rel#10:Subset#2.NONE.[1],all=true),
>>> rowcount=2.0, cumulative cost={inf}
>>>
>>>
>>> rel#17:AbstractConverter.NONE.[](input=rel#15:Subset#4.SPARK.[],convention=NONE,sort=[]),
>>> rowcount=2.0, cumulative cost={inf}
>>>
>>> rel#15:Subset#4.SPARK.[], best=null, importance=0.81
>>>
>>> rel#18:Subset#4.ENUMERABLE.[], best=null, importance=1.0
>>>
>>>
>>> rel#19:AbstractConverter.ENUMERABLE.[](input=rel#14:Subset#4.NONE.[],convention=ENUMERABLE,sort=[]),
>>> rowcount=2.0, cumulative cost={inf}
>>>
>>>
>>> rel#20:AbstractConverter.ENUMERABLE.[](input=rel#15:Subset#4.SPARK.[],convention=ENUMERABLE,sort=[]),
>>> rowcount=2.0, cumulative cost={inf}
>>>
>>>
>>>
>>> at
>>> org.apache.calcite.plan.volcano.RelSubset$CheapestPlanReplacer.visit(RelSubset.java:441)
>>>
>>> at
>>> org.apache.calcite.plan.volcano.RelSubset.buildCheapestPlan(RelSubset.java:291)
>>>
>>> at
>>> org.apache.calcite.plan.volcano.VolcanoPlanner.findBestExp(VolcanoPlanner.java:666)
>>>
>>> at org.apache.calcite.tools.Programs$5.run(Programs.java:326)
>>>
>>> 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
>
>
> Best regards,
> Alessandro

Reply via email to