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

Pavel Pereslegin updated IGNITE-22866:
--------------------------------------
    Description: 
*Description:*
Need to support recursive queries.

The query
{code:java}
WITH RECURSIVE t(n) AS (SELECT 1 UNION ALL SELECT n + 1 FROM t WHERE n < 100) 
SELECT sum(n) FROM t; {code}
should return
{code:java}
5050 {code}
currently returns error
{noformat}
org.apache.ignite.sql.SqlException: IGN-CMN-65535 
TraceId:c2961dbf-64fd-4806-a2d9-20368f8454e5 There are not enough rules to 
produce a node with desired properties: convention=IGNITE, distr=single, 
sort=[].
Missing conversions are LogicalRepeatUnion[convention: NONE -> IGNITE, distr: 
any -> single], LogicalRepeatUnion[convention: NONE -> IGNITE, distr: any -> 
random]
There are 2 empty subsets:
Empty subset 0: rel#92:RelSubset#6.IGNITE.single.[], the relevant part of the 
original plan is as follows
87:LogicalRepeatUnion(all=[true])
  78:LogicalTableSpool(subset=[rel#79:RelSubset#1.NONE.any.[0]], 
readType=[LAZY], writeType=[LAZY], table=[[T]])
    1:LogicalValues(subset=[rel#77:RelSubset#0.NONE.any.[0]], tuples=[[{ 1 }]])
  85:LogicalTableSpool(subset=[rel#86:RelSubset#5.NONE.any.[]], 
readType=[LAZY], writeType=[LAZY], table=[[T]])
    83:LogicalProject(subset=[rel#84:RelSubset#4.NONE.any.[]], EXPR$0=[+($0, 
1)])
      81:LogicalFilter(subset=[rel#82:RelSubset#3.NONE.any.[]], 
condition=[<($0, 100)])
        2:LogicalTableScan(subset=[rel#80:RelSubset#2.NONE.any.[]], table=[[T]])
... 
(part of the debug error output was cut out)

{noformat}

  was:
*Description:*
Need to support recursive queries.

The query
{code:java}
WITH RECURSIVE t(n) AS (SELECT 1 UNION ALL SELECT n + 1 FROM t WHERE n < 100) 
SELECT sum(n) FROM t; {code}
should return
{code:java}
5050 {code}
currently returns error
{noformat}
org.apache.ignite.sql.SqlException: IGN-CMN-65535 
TraceId:c2961dbf-64fd-4806-a2d9-20368f8454e5 There are not enough rules to 
produce a node with desired properties: convention=IGNITE, distr=single, 
sort=[].
Missing conversions are LogicalRepeatUnion[convention: NONE -> IGNITE, distr: 
any -> single], LogicalRepeatUnion[convention: NONE -> IGNITE, distr: any -> 
random]
There are 2 empty subsets:
Empty subset 0: rel#92:RelSubset#6.IGNITE.single.[], the relevant part of the 
original plan is as follows
87:LogicalRepeatUnion(all=[true])
  78:LogicalTableSpool(subset=[rel#79:RelSubset#1.NONE.any.[0]], 
readType=[LAZY], writeType=[LAZY], table=[[T]])
    1:LogicalValues(subset=[rel#77:RelSubset#0.NONE.any.[0]], tuples=[[{ 1 }]])
  85:LogicalTableSpool(subset=[rel#86:RelSubset#5.NONE.any.[]], 
readType=[LAZY], writeType=[LAZY], table=[[T]])
    83:LogicalProject(subset=[rel#84:RelSubset#4.NONE.any.[]], EXPR$0=[+($0, 
1)])
      81:LogicalFilter(subset=[rel#82:RelSubset#3.NONE.any.[]], 
condition=[<($0, 100)])
        2:LogicalTableScan(subset=[rel#80:RelSubset#2.NONE.any.[]], table=[[T]])

Empty subset 1: rel#102:RelSubset#6.IGNITE.random.[], the relevant part of the 
original plan is as follows
87:LogicalRepeatUnion(all=[true])
  78:LogicalTableSpool(subset=[rel#79:RelSubset#1.NONE.any.[0]], 
readType=[LAZY], writeType=[LAZY], table=[[T]])
    1:LogicalValues(subset=[rel#77:RelSubset#0.NONE.any.[0]], tuples=[[{ 1 }]])
  85:LogicalTableSpool(subset=[rel#86:RelSubset#5.NONE.any.[]], 
readType=[LAZY], writeType=[LAZY], table=[[T]])
    83:LogicalProject(subset=[rel#84:RelSubset#4.NONE.any.[]], EXPR$0=[+($0, 
1)])
      81:LogicalFilter(subset=[rel#82:RelSubset#3.NONE.any.[]], 
condition=[<($0, 100)])
        2:LogicalTableScan(subset=[rel#80:RelSubset#2.NONE.any.[]], table=[[T]])

Root: rel#91:RelSubset#7.IGNITE.single.[]
Original rel:
LogicalAggregate(subset=[rel#91:RelSubset#7.IGNITE.single.[]], group=[{}], 
EXPR$0=[SUM($0)]): rowcount = 1.0, cumulative cost = IgniteCost 
[rowCount=Infinity, cpu=Infinity, memory=Infinity, io=Infinity, 
network=Infinity], id = 89
  LogicalRepeatUnion(subset=[rel#88:RelSubset#6.NONE.any.[]], all=[true]): 
rowcount = 501.0, cumulative cost = IgniteCost [rowCount=Infinity, 
cpu=Infinity, memory=Infinity, io=Infinity, network=Infinity], id = 87
    LogicalTableSpool(subset=[rel#79:RelSubset#1.NONE.any.[0]], 
readType=[LAZY], writeType=[LAZY], table=[[T]]): rowcount = 1.0, cumulative 
cost = IgniteCost [rowCount=Infinity, cpu=Infinity, memory=Infinity, 
io=Infinity, network=Infinity], id = 78
      LogicalValues(subset=[rel#77:RelSubset#0.NONE.any.[0]], tuples=[[{ 1 
}]]): rowcount = 1.0, cumulative cost = IgniteCost [rowCount=Infinity, 
cpu=Infinity, memory=Infinity, io=Infinity, network=Infinity], id = 1
    LogicalTableSpool(subset=[rel#86:RelSubset#5.NONE.any.[]], readType=[LAZY], 
writeType=[LAZY], table=[[T]]): rowcount = 50.0, cumulative cost = IgniteCost 
[rowCount=Infinity, cpu=Infinity, memory=Infinity, io=Infinity, 
network=Infinity], id = 85
      LogicalProject(subset=[rel#84:RelSubset#4.NONE.any.[]], EXPR$0=[+($0, 
1)]): rowcount = 50.0, cumulative cost = IgniteCost [rowCount=Infinity, 
cpu=Infinity, memory=Infinity, io=Infinity, network=Infinity], id = 83
        LogicalFilter(subset=[rel#82:RelSubset#3.NONE.any.[]], condition=[<($0, 
100)]): rowcount = 50.0, cumulative cost = IgniteCost [rowCount=Infinity, 
cpu=Infinity, memory=Infinity, io=Infinity, network=Infinity], id = 81
          LogicalTableScan(subset=[rel#80:RelSubset#2.NONE.any.[]], 
table=[[T]]): rowcount = 100.0, cumulative cost = IgniteCost 
[rowCount=Infinity, cpu=Infinity, memory=Infinity, io=Infinity, 
network=Infinity], id = 2

Sets:
Set#0, type: RecordType(INTEGER EXPR$0)
        rel#77:RelSubset#0.NONE.any.[0], best=null
                rel#1:LogicalValues.NONE.any.[0](type=RecordType(INTEGER 
EXPR$0),tuples=[{ 1 }]), rowcount=1.0, cumulative cost=IgniteCost 
[rowCount=Infinity, cpu=Infinity, memory=Infinity, io=Infinity, 
network=Infinity]
Set#1, type: RecordType(INTEGER EXPR$0)
        rel#79:RelSubset#1.NONE.any.[0], best=null
                
rel#78:LogicalTableSpool.NONE.any.[0](input=RelSubset#77,readType=LAZY,writeType=LAZY,table=[T]),
 rowcount=1.0, cumulative cost=IgniteCost [rowCount=Infinity, cpu=Infinity, 
memory=Infinity, io=Infinity, network=Infinity]
Set#2, type: RecordType(INTEGER N)
        rel#80:RelSubset#2.NONE.any.[], best=null
                rel#2:LogicalTableScan.NONE.any.[](table=[T]), rowcount=100.0, 
cumulative cost=IgniteCost [rowCount=Infinity, cpu=Infinity, memory=Infinity, 
io=Infinity, network=Infinity]
Set#3, type: RecordType(INTEGER N)
        rel#82:RelSubset#3.NONE.any.[], best=null
                
rel#81:LogicalFilter.NONE.any.[](input=RelSubset#80,condition=<($0, 100)), 
rowcount=50.0, cumulative cost=IgniteCost [rowCount=Infinity, cpu=Infinity, 
memory=Infinity, io=Infinity, network=Infinity]
Set#4, type: RecordType(INTEGER EXPR$0)
        rel#84:RelSubset#4.NONE.any.[], best=null
                
rel#83:LogicalProject.NONE.any.[](input=RelSubset#82,exprs=[+($0, 1)]), 
rowcount=50.0, cumulative cost=IgniteCost [rowCount=Infinity, cpu=Infinity, 
memory=Infinity, io=Infinity, network=Infinity]
Set#5, type: RecordType(INTEGER EXPR$0)
        rel#86:RelSubset#5.NONE.any.[], best=null
                
rel#85:LogicalTableSpool.NONE.any.[](input=RelSubset#84,readType=LAZY,writeType=LAZY,table=[T]),
 rowcount=50.0, cumulative cost=IgniteCost [rowCount=Infinity, cpu=Infinity, 
memory=Infinity, io=Infinity, network=Infinity]
Set#6, type: RecordType(INTEGER EXPR$0)
        rel#88:RelSubset#6.NONE.any.[], best=null
                
rel#87:LogicalRepeatUnion.NONE.any.[](left=RelSubset#79,right=RelSubset#86,all=true),
 rowcount=501.0, cumulative cost=IgniteCost [rowCount=Infinity, cpu=Infinity, 
memory=Infinity, io=Infinity, network=Infinity]
        rel#92:RelSubset#6.IGNITE.single.[], best=null
        rel#102:RelSubset#6.IGNITE.random.[], best=null
Set#7, type: RecordType(BIGINT EXPR$0)
        rel#90:RelSubset#7.NONE.any.[], best=null
                
rel#89:LogicalAggregate.NONE.any.[](input=RelSubset#88,group={},EXPR$0=SUM($0)),
 rowcount=1.0, cumulative cost=IgniteCost [rowCount=Infinity, cpu=Infinity, 
memory=Infinity, io=Infinity, network=Infinity]
        rel#91:RelSubset#7.IGNITE.single.[], best=null
                
rel#93:ColocatedHashAggregate.IGNITE.single.[](input=RelSubset#92,group={},EXPR$0=SUM($0)),
 rowcount=1.0, cumulative cost=IgniteCost [rowCount=Infinity, cpu=Infinity, 
memory=Infinity, io=Infinity, network=Infinity]
                
rel#98:ReduceHashAggregate.IGNITE.single.[](input=RelSubset#96,group={},EXPR$0=SUM($0)),
 rowcount=1.0, cumulative cost=IgniteCost [rowCount=Infinity, cpu=Infinity, 
memory=Infinity, io=Infinity, network=Infinity]
                
rel#101:ColocatedSortAggregate.IGNITE.single.[](input=RelSubset#92,group={},EXPR$0=SUM($0),collation=[]),
 rowcount=1.0, cumulative cost=IgniteCost [rowCount=Infinity, cpu=Infinity, 
memory=Infinity, io=Infinity, network=Infinity]
                
rel#107:ReduceSortAggregate.IGNITE.single.[](input=RelSubset#105,group={},EXPR$0=SUM($0),collation=[]),
 rowcount=1.0, cumulative cost=IgniteCost [rowCount=Infinity, cpu=Infinity, 
memory=Infinity, io=Infinity, network=Infinity]
Set#8, type: RecordType(DECIMAL(32767, 0) _ACC0, TINYINT _GROUP_ID)
        rel#95:RelSubset#8.IGNITE.random.[], best=null
                
rel#94:MapHashAggregate.IGNITE.random.[](input=RelSubset#88,group={},EXPR$0=SUM($0)),
 rowcount=1.0, cumulative cost=IgniteCost [rowCount=Infinity, cpu=Infinity, 
memory=Infinity, io=Infinity, network=Infinity]
        rel#96:RelSubset#8.IGNITE.single.[], best=null
                
rel#97:Exchange.IGNITE.single.[](input=RelSubset#95,distribution=single), 
rowcount=1.0, cumulative cost=IgniteCost [rowCount=Infinity, cpu=Infinity, 
memory=Infinity, io=Infinity, network=Infinity]
                
rel#99:MapHashAggregate.IGNITE.single.[](input=RelSubset#92,group={},EXPR$0=SUM($0)),
 rowcount=1.0, cumulative cost=IgniteCost [rowCount=Infinity, cpu=Infinity, 
memory=Infinity, io=Infinity, network=Infinity]
Set#9, type: RecordType(DECIMAL(32767, 0) _ACC0)
        rel#104:RelSubset#9.IGNITE.random.[], best=null
                
rel#103:MapSortAggregate.IGNITE.random.[](input=RelSubset#102,group={},EXPR$0=SUM($0),collation=[]),
 rowcount=1.0, cumulative cost=IgniteCost [rowCount=Infinity, cpu=Infinity, 
memory=Infinity, io=Infinity, network=Infinity]
        rel#105:RelSubset#9.IGNITE.single.[], best=null
                
rel#106:Exchange.IGNITE.single.[](input=RelSubset#104,distribution=single), 
rowcount=1.0, cumulative cost=IgniteCost [rowCount=Infinity, cpu=Infinity, 
memory=Infinity, io=Infinity, network=Infinity]
                
rel#108:MapSortAggregate.IGNITE.single.[](input=RelSubset#92,group={},EXPR$0=SUM($0),collation=[]),
 rowcount=1.0, cumulative cost=IgniteCost [rowCount=Infinity, cpu=Infinity, 
memory=Infinity, io=Infinity, network=Infinity]

Graphviz:
digraph G {
        root [style=filled,label="Root"];
        subgraph cluster0{
                label="Set 0 RecordType(INTEGER EXPR$0)";
                rel1 [label="rel#1:LogicalValues\ntype=RecordType(INTEGER 
EXPR$0),tuples=[{ 1 }]\nrows=1.0, cost=IgniteCost [rowCount=Infinity, 
cpu=Infinity, memory=Infinity, io=Infinity, network=Infinity]",shape=box]
                subset77 [label="rel#77:RelSubset#0.NONE.any.[0]"]
        }
        subgraph cluster1{
                label="Set 1 RecordType(INTEGER EXPR$0)";
                rel78 
[label="rel#78:LogicalTableSpool\ninput=RelSubset#77,readType=LAZY,writeType=LAZY,table=[T]\nrows=1.0,
 cost=IgniteCost [rowCount=Infinity, cpu=Infinity, memory=Infinity, 
io=Infinity, network=Infinity]",shape=box]
                subset79 [label="rel#79:RelSubset#1.NONE.any.[0]"]
        }
        subgraph cluster2{
                label="Set 2 RecordType(INTEGER N)";
                rel2 [label="rel#2:LogicalTableScan\ntable=[T]\nrows=100.0, 
cost=IgniteCost [rowCount=Infinity, cpu=Infinity, memory=Infinity, io=Infinity, 
network=Infinity]",shape=box]
                subset80 [label="rel#80:RelSubset#2.NONE.any.[]"]
        }
        subgraph cluster3{
                label="Set 3 RecordType(INTEGER N)";
                rel81 
[label="rel#81:LogicalFilter\ninput=RelSubset#80,condition=<($0, 
100)\nrows=50.0, cost=IgniteCost [rowCount=Infinity, cpu=Infinity, 
memory=Infinity, io=Infinity, network=Infinity]",shape=box]
                subset82 [label="rel#82:RelSubset#3.NONE.any.[]"]
        }
        subgraph cluster4{
                label="Set 4 RecordType(INTEGER EXPR$0)";
                rel83 
[label="rel#83:LogicalProject\ninput=RelSubset#82,exprs=[+($0, 1)]\nrows=50.0, 
cost=IgniteCost [rowCount=Infinity, cpu=Infinity, memory=Infinity, io=Infinity, 
network=Infinity]",shape=box]
                subset84 [label="rel#84:RelSubset#4.NONE.any.[]"]
        }
        subgraph cluster5{
                label="Set 5 RecordType(INTEGER EXPR$0)";
                rel85 
[label="rel#85:LogicalTableSpool\ninput=RelSubset#84,readType=LAZY,writeType=LAZY,table=[T]\nrows=50.0,
 cost=IgniteCost [rowCount=Infinity, cpu=Infinity, memory=Infinity, 
io=Infinity, network=Infinity]",shape=box]
                subset86 [label="rel#86:RelSubset#5.NONE.any.[]"]
        }
        subgraph cluster6{
                label="Set 6 RecordType(INTEGER EXPR$0)";
                rel87 
[label="rel#87:LogicalRepeatUnion\nleft=RelSubset#79,right=RelSubset#86,all=true\nrows=501.0,
 cost=IgniteCost [rowCount=Infinity, cpu=Infinity, memory=Infinity, 
io=Infinity, network=Infinity]",shape=box]
                subset88 [label="rel#88:RelSubset#6.NONE.any.[]"]
                subset92 [label="rel#92:RelSubset#6.IGNITE.single.[]",color=red]
                subset102 
[label="rel#102:RelSubset#6.IGNITE.random.[]",color=red]
        }
        subgraph cluster7{
                label="Set 7 RecordType(BIGINT EXPR$0)";
                rel89 
[label="rel#89:LogicalAggregate\ninput=RelSubset#88,group={},EXPR$0=SUM($0)\nrows=1.0,
 cost=IgniteCost [rowCount=Infinity, cpu=Infinity, memory=Infinity, 
io=Infinity, network=Infinity]",shape=box]
                rel93 
[label="rel#93:ColocatedHashAggregate\ninput=RelSubset#92,group={},EXPR$0=SUM($0)\nrows=1.0,
 cost=IgniteCost [rowCount=Infinity, cpu=Infinity, memory=Infinity, 
io=Infinity, network=Infinity]",shape=box]
                rel98 
[label="rel#98:ReduceHashAggregate\ninput=RelSubset#96,group={},EXPR$0=SUM($0)\nrows=1.0,
 cost=IgniteCost [rowCount=Infinity, cpu=Infinity, memory=Infinity, 
io=Infinity, network=Infinity]",shape=box]
                rel101 
[label="rel#101:ColocatedSortAggregate\ninput=RelSubset#92,group={},EXPR$0=SUM($0),collation=[]\nrows=1.0,
 cost=IgniteCost [rowCount=Infinity, cpu=Infinity, memory=Infinity, 
io=Infinity, network=Infinity]",shape=box]
                rel107 
[label="rel#107:ReduceSortAggregate\ninput=RelSubset#105,group={},EXPR$0=SUM($0),collation=[]\nrows=1.0,
 cost=IgniteCost [rowCount=Infinity, cpu=Infinity, memory=Infinity, 
io=Infinity, network=Infinity]",shape=box]
                subset90 [label="rel#90:RelSubset#7.NONE.any.[]"]
                subset91 [label="rel#91:RelSubset#7.IGNITE.single.[]"]
        }
        subgraph cluster8{
                label="Set 8 RecordType(DECIMAL(32767, 0) _ACC0, TINYINT 
_GROUP_ID)";
                rel94 
[label="rel#94:MapHashAggregate\ninput=RelSubset#88,group={},EXPR$0=SUM($0)\nrows=1.0,
 cost=IgniteCost [rowCount=Infinity, cpu=Infinity, memory=Infinity, 
io=Infinity, network=Infinity]",shape=box]
                rel97 
[label="rel#97:Exchange\ninput=RelSubset#95,distribution=single\nrows=1.0, 
cost=IgniteCost [rowCount=Infinity, cpu=Infinity, memory=Infinity, io=Infinity, 
network=Infinity]",shape=box]
                rel99 
[label="rel#99:MapHashAggregate\ninput=RelSubset#92,group={},EXPR$0=SUM($0)\nrows=1.0,
 cost=IgniteCost [rowCount=Infinity, cpu=Infinity, memory=Infinity, 
io=Infinity, network=Infinity]",shape=box]
                subset95 [label="rel#95:RelSubset#8.IGNITE.random.[]"]
                subset96 [label="rel#96:RelSubset#8.IGNITE.single.[]"]
        }
        subgraph cluster9{
                label="Set 9 RecordType(DECIMAL(32767, 0) _ACC0)";
                rel103 
[label="rel#103:MapSortAggregate\ninput=RelSubset#102,group={},EXPR$0=SUM($0),collation=[]\nrows=1.0,
 cost=IgniteCost [rowCount=Infinity, cpu=Infinity, memory=Infinity, 
io=Infinity, network=Infinity]",shape=box]
                rel106 
[label="rel#106:Exchange\ninput=RelSubset#104,distribution=single\nrows=1.0, 
cost=IgniteCost [rowCount=Infinity, cpu=Infinity, memory=Infinity, io=Infinity, 
network=Infinity]",shape=box]
                rel108 
[label="rel#108:MapSortAggregate\ninput=RelSubset#92,group={},EXPR$0=SUM($0),collation=[]\nrows=1.0,
 cost=IgniteCost [rowCount=Infinity, cpu=Infinity, memory=Infinity, 
io=Infinity, network=Infinity]",shape=box]
                subset104 [label="rel#104:RelSubset#9.IGNITE.random.[]"]
                subset105 [label="rel#105:RelSubset#9.IGNITE.single.[]"]
        }
        root -> subset91;
        subset77 -> rel1;
        subset79 -> rel78; rel78 -> subset77;
        subset80 -> rel2;
        subset82 -> rel81; rel81 -> subset80;
        subset84 -> rel83; rel83 -> subset82;
        subset86 -> rel85; rel85 -> subset84;
        subset88 -> rel87; rel87 -> subset79[label="0"]; rel87 -> 
subset86[label="1"];
        subset90 -> rel89; rel89 -> subset88;
        subset91 -> rel93; rel93 -> subset92;
        subset91 -> rel98; rel98 -> subset96;
        subset91 -> rel101; rel101 -> subset92;
        subset91 -> rel107; rel107 -> subset105;
        subset95 -> rel94; rel94 -> subset88;
        subset96 -> rel97; rel97 -> subset95;
        subset96 -> rel99; rel99 -> subset92;
        subset104 -> rel103; rel103 -> subset102;
        subset105 -> rel106; rel106 -> subset104;
        subset105 -> rel108; rel108 -> subset92;
}

        at 
java.base/java.lang.invoke.MethodHandle.invokeWithArguments(MethodHandle.java:710)
        at 
org.apache.ignite.internal.util.ExceptionUtils$1.copy(ExceptionUtils.java:789)
        at 
org.apache.ignite.internal.util.ExceptionUtils$ExceptionFactory.createCopy(ExceptionUtils.java:723)
        at 
org.apache.ignite.internal.util.ExceptionUtils.copyExceptionWithCause(ExceptionUtils.java:525)
        at 
org.apache.ignite.internal.util.ExceptionUtils.copyExceptionWithCauseInternal(ExceptionUtils.java:658)
        at 
org.apache.ignite.internal.util.ExceptionUtils.copyExceptionWithCause(ExceptionUtils.java:476)
        at 
org.apache.ignite.internal.sql.api.IgniteSqlImpl.execute(IgniteSqlImpl.java:222)
        at 
org.apache.ignite.internal.sql.api.PublicApiThreadingIgniteSql.lambda$execute$2(PublicApiThreadingIgniteSql.java:70)
        at 
org.apache.ignite.internal.thread.PublicApiThreading.executeWithRole(PublicApiThreading.java:144)
        at 
org.apache.ignite.internal.thread.PublicApiThreading.execUserSyncOperation(PublicApiThreading.java:102)
        at 
org.apache.ignite.internal.sql.api.PublicApiThreadingIgniteSql.execute(PublicApiThreadingIgniteSql.java:70)
        at 
org.apache.ignite.internal.ClusterPerClassIntegrationTest.sql(ClusterPerClassIntegrationTest.java:376)
        at 
org.apache.ignite.internal.ClusterPerClassIntegrationTest.sql(ClusterPerClassIntegrationTest.java:390)
        at 
org.apache.ignite.internal.ClusterPerClassIntegrationTest.sql(ClusterPerClassIntegrationTest.java:386)
        at 
org.apache.ignite.internal.ClusterPerClassIntegrationTest.sql(ClusterPerClassIntegrationTest.java:382)
        at 
org.apache.ignite.internal.ClusterPerClassIntegrationTest.sql(ClusterPerClassIntegrationTest.java:349)
        at 
org.apache.ignite.internal.sql.api.ItSqlApiBaseTest.testX(ItSqlApiBaseTest.java:94)
        at java.base/java.lang.reflect.Method.invoke(Method.java:566)
        at java.base/java.util.ArrayList.forEach(ArrayList.java:1541)
        at java.base/java.util.ArrayList.forEach(ArrayList.java:1541)
Caused by: java.util.concurrent.CompletionException: 
org.apache.ignite.sql.SqlException: IGN-CMN-65535 
TraceId:c2961dbf-64fd-4806-a2d9-20368f8454e5 There are not enough rules to 
produce a node with desired properties: convention=IGNITE, distr=single, 
sort=[].
Missing conversions are LogicalRepeatUnion[convention: NONE -> IGNITE, distr: 
any -> single], LogicalRepeatUnion[convention: NONE -> IGNITE, distr: any -> 
random]
There are 2 empty subsets:
Empty subset 0: rel#92:RelSubset#6.IGNITE.single.[], the relevant part of the 
original plan is as follows
87:LogicalRepeatUnion(all=[true])
  78:LogicalTableSpool(subset=[rel#79:RelSubset#1.NONE.any.[0]], 
readType=[LAZY], writeType=[LAZY], table=[[T]])
    1:LogicalValues(subset=[rel#77:RelSubset#0.NONE.any.[0]], tuples=[[{ 1 }]])
  85:LogicalTableSpool(subset=[rel#86:RelSubset#5.NONE.any.[]], 
readType=[LAZY], writeType=[LAZY], table=[[T]])
    83:LogicalProject(subset=[rel#84:RelSubset#4.NONE.any.[]], EXPR$0=[+($0, 
1)])
      81:LogicalFilter(subset=[rel#82:RelSubset#3.NONE.any.[]], 
condition=[<($0, 100)])
        2:LogicalTableScan(subset=[rel#80:RelSubset#2.NONE.any.[]], table=[[T]])

Empty subset 1: rel#102:RelSubset#6.IGNITE.random.[], the relevant part of the 
original plan is as follows
87:LogicalRepeatUnion(all=[true])
  78:LogicalTableSpool(subset=[rel#79:RelSubset#1.NONE.any.[0]], 
readType=[LAZY], writeType=[LAZY], table=[[T]])
    1:LogicalValues(subset=[rel#77:RelSubset#0.NONE.any.[0]], tuples=[[{ 1 }]])
  85:LogicalTableSpool(subset=[rel#86:RelSubset#5.NONE.any.[]], 
readType=[LAZY], writeType=[LAZY], table=[[T]])
    83:LogicalProject(subset=[rel#84:RelSubset#4.NONE.any.[]], EXPR$0=[+($0, 
1)])
      81:LogicalFilter(subset=[rel#82:RelSubset#3.NONE.any.[]], 
condition=[<($0, 100)])
        2:LogicalTableScan(subset=[rel#80:RelSubset#2.NONE.any.[]], table=[[T]])

Root: rel#91:RelSubset#7.IGNITE.single.[]
Original rel:
LogicalAggregate(subset=[rel#91:RelSubset#7.IGNITE.single.[]], group=[{}], 
EXPR$0=[SUM($0)]): rowcount = 1.0, cumulative cost = IgniteCost 
[rowCount=Infinity, cpu=Infinity, memory=Infinity, io=Infinity, 
network=Infinity], id = 89
  LogicalRepeatUnion(subset=[rel#88:RelSubset#6.NONE.any.[]], all=[true]): 
rowcount = 501.0, cumulative cost = IgniteCost [rowCount=Infinity, 
cpu=Infinity, memory=Infinity, io=Infinity, network=Infinity], id = 87
    LogicalTableSpool(subset=[rel#79:RelSubset#1.NONE.any.[0]], 
readType=[LAZY], writeType=[LAZY], table=[[T]]): rowcount = 1.0, cumulative 
cost = IgniteCost [rowCount=Infinity, cpu=Infinity, memory=Infinity, 
io=Infinity, network=Infinity], id = 78
      LogicalValues(subset=[rel#77:RelSubset#0.NONE.any.[0]], tuples=[[{ 1 
}]]): rowcount = 1.0, cumulative cost = IgniteCost [rowCount=Infinity, 
cpu=Infinity, memory=Infinity, io=Infinity, network=Infinity], id = 1
    LogicalTableSpool(subset=[rel#86:RelSubset#5.NONE.any.[]], readType=[LAZY], 
writeType=[LAZY], table=[[T]]): rowcount = 50.0, cumulative cost = IgniteCost 
[rowCount=Infinity, cpu=Infinity, memory=Infinity, io=Infinity, 
network=Infinity], id = 85
      LogicalProject(subset=[rel#84:RelSubset#4.NONE.any.[]], EXPR$0=[+($0, 
1)]): rowcount = 50.0, cumulative cost = IgniteCost [rowCount=Infinity, 
cpu=Infinity, memory=Infinity, io=Infinity, network=Infinity], id = 83
        LogicalFilter(subset=[rel#82:RelSubset#3.NONE.any.[]], condition=[<($0, 
100)]): rowcount = 50.0, cumulative cost = IgniteCost [rowCount=Infinity, 
cpu=Infinity, memory=Infinity, io=Infinity, network=Infinity], id = 81
          LogicalTableScan(subset=[rel#80:RelSubset#2.NONE.any.[]], 
table=[[T]]): rowcount = 100.0, cumulative cost = IgniteCost 
[rowCount=Infinity, cpu=Infinity, memory=Infinity, io=Infinity, 
network=Infinity], id = 2

Sets:
Set#0, type: RecordType(INTEGER EXPR$0)
        rel#77:RelSubset#0.NONE.any.[0], best=null
                rel#1:LogicalValues.NONE.any.[0](type=RecordType(INTEGER 
EXPR$0),tuples=[{ 1 }]), rowcount=1.0, cumulative cost=IgniteCost 
[rowCount=Infinity, cpu=Infinity, memory=Infinity, io=Infinity, 
network=Infinity]
Set#1, type: RecordType(INTEGER EXPR$0)
        rel#79:RelSubset#1.NONE.any.[0], best=null
                
rel#78:LogicalTableSpool.NONE.any.[0](input=RelSubset#77,readType=LAZY,writeType=LAZY,table=[T]),
 rowcount=1.0, cumulative cost=IgniteCost [rowCount=Infinity, cpu=Infinity, 
memory=Infinity, io=Infinity, network=Infinity]
Set#2, type: RecordType(INTEGER N)
        rel#80:RelSubset#2.NONE.any.[], best=null
                rel#2:LogicalTableScan.NONE.any.[](table=[T]), rowcount=100.0, 
cumulative cost=IgniteCost [rowCount=Infinity, cpu=Infinity, memory=Infinity, 
io=Infinity, network=Infinity]
Set#3, type: RecordType(INTEGER N)
        rel#82:RelSubset#3.NONE.any.[], best=null
                
rel#81:LogicalFilter.NONE.any.[](input=RelSubset#80,condition=<($0, 100)), 
rowcount=50.0, cumulative cost=IgniteCost [rowCount=Infinity, cpu=Infinity, 
memory=Infinity, io=Infinity, network=Infinity]
Set#4, type: RecordType(INTEGER EXPR$0)
        rel#84:RelSubset#4.NONE.any.[], best=null
                
rel#83:LogicalProject.NONE.any.[](input=RelSubset#82,exprs=[+($0, 1)]), 
rowcount=50.0, cumulative cost=IgniteCost [rowCount=Infinity, cpu=Infinity, 
memory=Infinity, io=Infinity, network=Infinity]
Set#5, type: RecordType(INTEGER EXPR$0)
        rel#86:RelSubset#5.NONE.any.[], best=null
                
rel#85:LogicalTableSpool.NONE.any.[](input=RelSubset#84,readType=LAZY,writeType=LAZY,table=[T]),
 rowcount=50.0, cumulative cost=IgniteCost [rowCount=Infinity, cpu=Infinity, 
memory=Infinity, io=Infinity, network=Infinity]
Set#6, type: RecordType(INTEGER EXPR$0)
        rel#88:RelSubset#6.NONE.any.[], best=null
                
rel#87:LogicalRepeatUnion.NONE.any.[](left=RelSubset#79,right=RelSubset#86,all=true),
 rowcount=501.0, cumulative cost=IgniteCost [rowCount=Infinity, cpu=Infinity, 
memory=Infinity, io=Infinity, network=Infinity]
        rel#92:RelSubset#6.IGNITE.single.[], best=null
        rel#102:RelSubset#6.IGNITE.random.[], best=null
Set#7, type: RecordType(BIGINT EXPR$0)
        rel#90:RelSubset#7.NONE.any.[], best=null
                
rel#89:LogicalAggregate.NONE.any.[](input=RelSubset#88,group={},EXPR$0=SUM($0)),
 rowcount=1.0, cumulative cost=IgniteCost [rowCount=Infinity, cpu=Infinity, 
memory=Infinity, io=Infinity, network=Infinity]
        rel#91:RelSubset#7.IGNITE.single.[], best=null
                
rel#93:ColocatedHashAggregate.IGNITE.single.[](input=RelSubset#92,group={},EXPR$0=SUM($0)),
 rowcount=1.0, cumulative cost=IgniteCost [rowCount=Infinity, cpu=Infinity, 
memory=Infinity, io=Infinity, network=Infinity]
                
rel#98:ReduceHashAggregate.IGNITE.single.[](input=RelSubset#96,group={},EXPR$0=SUM($0)),
 rowcount=1.0, cumulative cost=IgniteCost [rowCount=Infinity, cpu=Infinity, 
memory=Infinity, io=Infinity, network=Infinity]
                
rel#101:ColocatedSortAggregate.IGNITE.single.[](input=RelSubset#92,group={},EXPR$0=SUM($0),collation=[]),
 rowcount=1.0, cumulative cost=IgniteCost [rowCount=Infinity, cpu=Infinity, 
memory=Infinity, io=Infinity, network=Infinity]
                
rel#107:ReduceSortAggregate.IGNITE.single.[](input=RelSubset#105,group={},EXPR$0=SUM($0),collation=[]),
 rowcount=1.0, cumulative cost=IgniteCost [rowCount=Infinity, cpu=Infinity, 
memory=Infinity, io=Infinity, network=Infinity]
Set#8, type: RecordType(DECIMAL(32767, 0) _ACC0, TINYINT _GROUP_ID)
        rel#95:RelSubset#8.IGNITE.random.[], best=null
                
rel#94:MapHashAggregate.IGNITE.random.[](input=RelSubset#88,group={},EXPR$0=SUM($0)),
 rowcount=1.0, cumulative cost=IgniteCost [rowCount=Infinity, cpu=Infinity, 
memory=Infinity, io=Infinity, network=Infinity]
        rel#96:RelSubset#8.IGNITE.single.[], best=null
                
rel#97:Exchange.IGNITE.single.[](input=RelSubset#95,distribution=single), 
rowcount=1.0, cumulative cost=IgniteCost [rowCount=Infinity, cpu=Infinity, 
memory=Infinity, io=Infinity, network=Infinity]
                
rel#99:MapHashAggregate.IGNITE.single.[](input=RelSubset#92,group={},EXPR$0=SUM($0)),
 rowcount=1.0, cumulative cost=IgniteCost [rowCount=Infinity, cpu=Infinity, 
memory=Infinity, io=Infinity, network=Infinity]
Set#9, type: RecordType(DECIMAL(32767, 0) _ACC0)
        rel#104:RelSubset#9.IGNITE.random.[], best=null
                
rel#103:MapSortAggregate.IGNITE.random.[](input=RelSubset#102,group={},EXPR$0=SUM($0),collation=[]),
 rowcount=1.0, cumulative cost=IgniteCost [rowCount=Infinity, cpu=Infinity, 
memory=Infinity, io=Infinity, network=Infinity]
        rel#105:RelSubset#9.IGNITE.single.[], best=null
                
rel#106:Exchange.IGNITE.single.[](input=RelSubset#104,distribution=single), 
rowcount=1.0, cumulative cost=IgniteCost [rowCount=Infinity, cpu=Infinity, 
memory=Infinity, io=Infinity, network=Infinity]
                
rel#108:MapSortAggregate.IGNITE.single.[](input=RelSubset#92,group={},EXPR$0=SUM($0),collation=[]),
 rowcount=1.0, cumulative cost=IgniteCost [rowCount=Infinity, cpu=Infinity, 
memory=Infinity, io=Infinity, network=Infinity]

Graphviz:
digraph G {
        root [style=filled,label="Root"];
        subgraph cluster0{
                label="Set 0 RecordType(INTEGER EXPR$0)";
                rel1 [label="rel#1:LogicalValues\ntype=RecordType(INTEGER 
EXPR$0),tuples=[{ 1 }]\nrows=1.0, cost=IgniteCost [rowCount=Infinity, 
cpu=Infinity, memory=Infinity, io=Infinity, network=Infinity]",shape=box]
                subset77 [label="rel#77:RelSubset#0.NONE.any.[0]"]
        }
        subgraph cluster1{
                label="Set 1 RecordType(INTEGER EXPR$0)";
                rel78 
[label="rel#78:LogicalTableSpool\ninput=RelSubset#77,readType=LAZY,writeType=LAZY,table=[T]\nrows=1.0,
 cost=IgniteCost [rowCount=Infinity, cpu=Infinity, memory=Infinity, 
io=Infinity, network=Infinity]",shape=box]
                subset79 [label="rel#79:RelSubset#1.NONE.any.[0]"]
        }
        subgraph cluster2{
                label="Set 2 RecordType(INTEGER N)";
                rel2 [label="rel#2:LogicalTableScan\ntable=[T]\nrows=100.0, 
cost=IgniteCost [rowCount=Infinity, cpu=Infinity, memory=Infinity, io=Infinity, 
network=Infinity]",shape=box]
                subset80 [label="rel#80:RelSubset#2.NONE.any.[]"]
        }
        subgraph cluster3{
                label="Set 3 RecordType(INTEGER N)";
                rel81 
[label="rel#81:LogicalFilter\ninput=RelSubset#80,condition=<($0, 
100)\nrows=50.0, cost=IgniteCost [rowCount=Infinity, cpu=Infinity, 
memory=Infinity, io=Infinity, network=Infinity]",shape=box]
                subset82 [label="rel#82:RelSubset#3.NONE.any.[]"]
        }
        subgraph cluster4{
                label="Set 4 RecordType(INTEGER EXPR$0)";
                rel83 
[label="rel#83:LogicalProject\ninput=RelSubset#82,exprs=[+($0, 1)]\nrows=50.0, 
cost=IgniteCost [rowCount=Infinity, cpu=Infinity, memory=Infinity, io=Infinity, 
network=Infinity]",shape=box]
                subset84 [label="rel#84:RelSubset#4.NONE.any.[]"]
        }
        subgraph cluster5{
                label="Set 5 RecordType(INTEGER EXPR$0)";
                rel85 
[label="rel#85:LogicalTableSpool\ninput=RelSubset#84,readType=LAZY,writeType=LAZY,table=[T]\nrows=50.0,
 cost=IgniteCost [rowCount=Infinity, cpu=Infinity, memory=Infinity, 
io=Infinity, network=Infinity]",shape=box]
                subset86 [label="rel#86:RelSubset#5.NONE.any.[]"]
        }
        subgraph cluster6{
                label="Set 6 RecordType(INTEGER EXPR$0)";
                rel87 
[label="rel#87:LogicalRepeatUnion\nleft=RelSubset#79,right=RelSubset#86,all=true\nrows=501.0,
 cost=IgniteCost [rowCount=Infinity, cpu=Infinity, memory=Infinity, 
io=Infinity, network=Infinity]",shape=box]
                subset88 [label="rel#88:RelSubset#6.NONE.any.[]"]
                subset92 [label="rel#92:RelSubset#6.IGNITE.single.[]",color=red]
                subset102 
[label="rel#102:RelSubset#6.IGNITE.random.[]",color=red]
        }
        subgraph cluster7{
                label="Set 7 RecordType(BIGINT EXPR$0)";
                rel89 
[label="rel#89:LogicalAggregate\ninput=RelSubset#88,group={},EXPR$0=SUM($0)\nrows=1.0,
 cost=IgniteCost [rowCount=Infinity, cpu=Infinity, memory=Infinity, 
io=Infinity, network=Infinity]",shape=box]
                rel93 
[label="rel#93:ColocatedHashAggregate\ninput=RelSubset#92,group={},EXPR$0=SUM($0)\nrows=1.0,
 cost=IgniteCost [rowCount=Infinity, cpu=Infinity, memory=Infinity, 
io=Infinity, network=Infinity]",shape=box]
                rel98 
[label="rel#98:ReduceHashAggregate\ninput=RelSubset#96,group={},EXPR$0=SUM($0)\nrows=1.0,
 cost=IgniteCost [rowCount=Infinity, cpu=Infinity, memory=Infinity, 
io=Infinity, network=Infinity]",shape=box]
                rel101 
[label="rel#101:ColocatedSortAggregate\ninput=RelSubset#92,group={},EXPR$0=SUM($0),collation=[]\nrows=1.0,
 cost=IgniteCost [rowCount=Infinity, cpu=Infinity, memory=Infinity, 
io=Infinity, network=Infinity]",shape=box]
                rel107 
[label="rel#107:ReduceSortAggregate\ninput=RelSubset#105,group={},EXPR$0=SUM($0),collation=[]\nrows=1.0,
 cost=IgniteCost [rowCount=Infinity, cpu=Infinity, memory=Infinity, 
io=Infinity, network=Infinity]",shape=box]
                subset90 [label="rel#90:RelSubset#7.NONE.any.[]"]
                subset91 [label="rel#91:RelSubset#7.IGNITE.single.[]"]
        }
        subgraph cluster8{
                label="Set 8 RecordType(DECIMAL(32767, 0) _ACC0, TINYINT 
_GROUP_ID)";
                rel94 
[label="rel#94:MapHashAggregate\ninput=RelSubset#88,group={},EXPR$0=SUM($0)\nrows=1.0,
 cost=IgniteCost [rowCount=Infinity, cpu=Infinity, memory=Infinity, 
io=Infinity, network=Infinity]",shape=box]
                rel97 
[label="rel#97:Exchange\ninput=RelSubset#95,distribution=single\nrows=1.0, 
cost=IgniteCost [rowCount=Infinity, cpu=Infinity, memory=Infinity, io=Infinity, 
network=Infinity]",shape=box]
                rel99 
[label="rel#99:MapHashAggregate\ninput=RelSubset#92,group={},EXPR$0=SUM($0)\nrows=1.0,
 cost=IgniteCost [rowCount=Infinity, cpu=Infinity, memory=Infinity, 
io=Infinity, network=Infinity]",shape=box]
                subset95 [label="rel#95:RelSubset#8.IGNITE.random.[]"]
                subset96 [label="rel#96:RelSubset#8.IGNITE.single.[]"]
        }
        subgraph cluster9{
                label="Set 9 RecordType(DECIMAL(32767, 0) _ACC0)";
                rel103 
[label="rel#103:MapSortAggregate\ninput=RelSubset#102,group={},EXPR$0=SUM($0),collation=[]\nrows=1.0,
 cost=IgniteCost [rowCount=Infinity, cpu=Infinity, memory=Infinity, 
io=Infinity, network=Infinity]",shape=box]
                rel106 
[label="rel#106:Exchange\ninput=RelSubset#104,distribution=single\nrows=1.0, 
cost=IgniteCost [rowCount=Infinity, cpu=Infinity, memory=Infinity, io=Infinity, 
network=Infinity]",shape=box]
                rel108 
[label="rel#108:MapSortAggregate\ninput=RelSubset#92,group={},EXPR$0=SUM($0),collation=[]\nrows=1.0,
 cost=IgniteCost [rowCount=Infinity, cpu=Infinity, memory=Infinity, 
io=Infinity, network=Infinity]",shape=box]
                subset104 [label="rel#104:RelSubset#9.IGNITE.random.[]"]
                subset105 [label="rel#105:RelSubset#9.IGNITE.single.[]"]
        }
        root -> subset91;
        subset77 -> rel1;
        subset79 -> rel78; rel78 -> subset77;
        subset80 -> rel2;
        subset82 -> rel81; rel81 -> subset80;
        subset84 -> rel83; rel83 -> subset82;
        subset86 -> rel85; rel85 -> subset84;
        subset88 -> rel87; rel87 -> subset79[label="0"]; rel87 -> 
subset86[label="1"];
        subset90 -> rel89; rel89 -> subset88;
        subset91 -> rel93; rel93 -> subset92;
        subset91 -> rel98; rel98 -> subset96;
        subset91 -> rel101; rel101 -> subset92;
        subset91 -> rel107; rel107 -> subset105;
        subset95 -> rel94; rel94 -> subset88;
        subset96 -> rel97; rel97 -> subset95;
        subset96 -> rel99; rel99 -> subset92;
        subset104 -> rel103; rel103 -> subset102;
        subset105 -> rel106; rel106 -> subset104;
        subset105 -> rel108; rel108 -> subset92;
}
        at 
org.apache.ignite.internal.sql.api.IgniteSqlImpl.lambda$executeAsyncInternal$5(IgniteSqlImpl.java:379)
        at 
java.base/java.util.concurrent.CompletableFuture.uniExceptionally(CompletableFuture.java:986)
        at 
java.base/java.util.concurrent.CompletableFuture$UniExceptionally.tryFire(CompletableFuture.java:970)
        at 
java.base/java.util.concurrent.CompletableFuture.postComplete(CompletableFuture.java:506)
        at 
java.base/java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1705)
        at 
java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
        at 
java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
        at java.base/java.lang.Thread.run(Thread.java:834)
Caused by: org.apache.ignite.sql.SqlException: IGN-CMN-65535 
TraceId:c2961dbf-64fd-4806-a2d9-20368f8454e5 There are not enough rules to 
produce a node with desired properties: convention=IGNITE, distr=single, 
sort=[].
Missing conversions are LogicalRepeatUnion[convention: NONE -> IGNITE, distr: 
any -> single], LogicalRepeatUnion[convention: NONE -> IGNITE, distr: any -> 
random]
There are 2 empty subsets:
Empty subset 0: rel#92:RelSubset#6.IGNITE.single.[], the relevant part of the 
original plan is as follows
87:LogicalRepeatUnion(all=[true])
  78:LogicalTableSpool(subset=[rel#79:RelSubset#1.NONE.any.[0]], 
readType=[LAZY], writeType=[LAZY], table=[[T]])
    1:LogicalValues(subset=[rel#77:RelSubset#0.NONE.any.[0]], tuples=[[{ 1 }]])
  85:LogicalTableSpool(subset=[rel#86:RelSubset#5.NONE.any.[]], 
readType=[LAZY], writeType=[LAZY], table=[[T]])
    83:LogicalProject(subset=[rel#84:RelSubset#4.NONE.any.[]], EXPR$0=[+($0, 
1)])
      81:LogicalFilter(subset=[rel#82:RelSubset#3.NONE.any.[]], 
condition=[<($0, 100)])
        2:LogicalTableScan(subset=[rel#80:RelSubset#2.NONE.any.[]], table=[[T]])

Empty subset 1: rel#102:RelSubset#6.IGNITE.random.[], the relevant part of the 
original plan is as follows
87:LogicalRepeatUnion(all=[true])
  78:LogicalTableSpool(subset=[rel#79:RelSubset#1.NONE.any.[0]], 
readType=[LAZY], writeType=[LAZY], table=[[T]])
    1:LogicalValues(subset=[rel#77:RelSubset#0.NONE.any.[0]], tuples=[[{ 1 }]])
  85:LogicalTableSpool(subset=[rel#86:RelSubset#5.NONE.any.[]], 
readType=[LAZY], writeType=[LAZY], table=[[T]])
    83:LogicalProject(subset=[rel#84:RelSubset#4.NONE.any.[]], EXPR$0=[+($0, 
1)])
      81:LogicalFilter(subset=[rel#82:RelSubset#3.NONE.any.[]], 
condition=[<($0, 100)])
        2:LogicalTableScan(subset=[rel#80:RelSubset#2.NONE.any.[]], table=[[T]])

Root: rel#91:RelSubset#7.IGNITE.single.[]
Original rel:
LogicalAggregate(subset=[rel#91:RelSubset#7.IGNITE.single.[]], group=[{}], 
EXPR$0=[SUM($0)]): rowcount = 1.0, cumulative cost = IgniteCost 
[rowCount=Infinity, cpu=Infinity, memory=Infinity, io=Infinity, 
network=Infinity], id = 89
  LogicalRepeatUnion(subset=[rel#88:RelSubset#6.NONE.any.[]], all=[true]): 
rowcount = 501.0, cumulative cost = IgniteCost [rowCount=Infinity, 
cpu=Infinity, memory=Infinity, io=Infinity, network=Infinity], id = 87
    LogicalTableSpool(subset=[rel#79:RelSubset#1.NONE.any.[0]], 
readType=[LAZY], writeType=[LAZY], table=[[T]]): rowcount = 1.0, cumulative 
cost = IgniteCost [rowCount=Infinity, cpu=Infinity, memory=Infinity, 
io=Infinity, network=Infinity], id = 78
      LogicalValues(subset=[rel#77:RelSubset#0.NONE.any.[0]], tuples=[[{ 1 
}]]): rowcount = 1.0, cumulative cost = IgniteCost [rowCount=Infinity, 
cpu=Infinity, memory=Infinity, io=Infinity, network=Infinity], id = 1
    LogicalTableSpool(subset=[rel#86:RelSubset#5.NONE.any.[]], readType=[LAZY], 
writeType=[LAZY], table=[[T]]): rowcount = 50.0, cumulative cost = IgniteCost 
[rowCount=Infinity, cpu=Infinity, memory=Infinity, io=Infinity, 
network=Infinity], id = 85
      LogicalProject(subset=[rel#84:RelSubset#4.NONE.any.[]], EXPR$0=[+($0, 
1)]): rowcount = 50.0, cumulative cost = IgniteCost [rowCount=Infinity, 
cpu=Infinity, memory=Infinity, io=Infinity, network=Infinity], id = 83
        LogicalFilter(subset=[rel#82:RelSubset#3.NONE.any.[]], condition=[<($0, 
100)]): rowcount = 50.0, cumulative cost = IgniteCost [rowCount=Infinity, 
cpu=Infinity, memory=Infinity, io=Infinity, network=Infinity], id = 81
          LogicalTableScan(subset=[rel#80:RelSubset#2.NONE.any.[]], 
table=[[T]]): rowcount = 100.0, cumulative cost = IgniteCost 
[rowCount=Infinity, cpu=Infinity, memory=Infinity, io=Infinity, 
network=Infinity], id = 2

Sets:
Set#0, type: RecordType(INTEGER EXPR$0)
        rel#77:RelSubset#0.NONE.any.[0], best=null
                rel#1:LogicalValues.NONE.any.[0](type=RecordType(INTEGER 
EXPR$0),tuples=[{ 1 }]), rowcount=1.0, cumulative cost=IgniteCost 
[rowCount=Infinity, cpu=Infinity, memory=Infinity, io=Infinity, 
network=Infinity]
Set#1, type: RecordType(INTEGER EXPR$0)
        rel#79:RelSubset#1.NONE.any.[0], best=null
                
rel#78:LogicalTableSpool.NONE.any.[0](input=RelSubset#77,readType=LAZY,writeType=LAZY,table=[T]),
 rowcount=1.0, cumulative cost=IgniteCost [rowCount=Infinity, cpu=Infinity, 
memory=Infinity, io=Infinity, network=Infinity]
Set#2, type: RecordType(INTEGER N)
        rel#80:RelSubset#2.NONE.any.[], best=null
                rel#2:LogicalTableScan.NONE.any.[](table=[T]), rowcount=100.0, 
cumulative cost=IgniteCost [rowCount=Infinity, cpu=Infinity, memory=Infinity, 
io=Infinity, network=Infinity]
Set#3, type: RecordType(INTEGER N)
        rel#82:RelSubset#3.NONE.any.[], best=null
                
rel#81:LogicalFilter.NONE.any.[](input=RelSubset#80,condition=<($0, 100)), 
rowcount=50.0, cumulative cost=IgniteCost [rowCount=Infinity, cpu=Infinity, 
memory=Infinity, io=Infinity, network=Infinity]
Set#4, type: RecordType(INTEGER EXPR$0)
        rel#84:RelSubset#4.NONE.any.[], best=null
                
rel#83:LogicalProject.NONE.any.[](input=RelSubset#82,exprs=[+($0, 1)]), 
rowcount=50.0, cumulative cost=IgniteCost [rowCount=Infinity, cpu=Infinity, 
memory=Infinity, io=Infinity, network=Infinity]
Set#5, type: RecordType(INTEGER EXPR$0)
        rel#86:RelSubset#5.NONE.any.[], best=null
                
rel#85:LogicalTableSpool.NONE.any.[](input=RelSubset#84,readType=LAZY,writeType=LAZY,table=[T]),
 rowcount=50.0, cumulative cost=IgniteCost [rowCount=Infinity, cpu=Infinity, 
memory=Infinity, io=Infinity, network=Infinity]
Set#6, type: RecordType(INTEGER EXPR$0)
        rel#88:RelSubset#6.NONE.any.[], best=null
                
rel#87:LogicalRepeatUnion.NONE.any.[](left=RelSubset#79,right=RelSubset#86,all=true),
 rowcount=501.0, cumulative cost=IgniteCost [rowCount=Infinity, cpu=Infinity, 
memory=Infinity, io=Infinity, network=Infinity]
        rel#92:RelSubset#6.IGNITE.single.[], best=null
        rel#102:RelSubset#6.IGNITE.random.[], best=null
Set#7, type: RecordType(BIGINT EXPR$0)
        rel#90:RelSubset#7.NONE.any.[], best=null
                
rel#89:LogicalAggregate.NONE.any.[](input=RelSubset#88,group={},EXPR$0=SUM($0)),
 rowcount=1.0, cumulative cost=IgniteCost [rowCount=Infinity, cpu=Infinity, 
memory=Infinity, io=Infinity, network=Infinity]
        rel#91:RelSubset#7.IGNITE.single.[], best=null
                
rel#93:ColocatedHashAggregate.IGNITE.single.[](input=RelSubset#92,group={},EXPR$0=SUM($0)),
 rowcount=1.0, cumulative cost=IgniteCost [rowCount=Infinity, cpu=Infinity, 
memory=Infinity, io=Infinity, network=Infinity]
                
rel#98:ReduceHashAggregate.IGNITE.single.[](input=RelSubset#96,group={},EXPR$0=SUM($0)),
 rowcount=1.0, cumulative cost=IgniteCost [rowCount=Infinity, cpu=Infinity, 
memory=Infinity, io=Infinity, network=Infinity]
                
rel#101:ColocatedSortAggregate.IGNITE.single.[](input=RelSubset#92,group={},EXPR$0=SUM($0),collation=[]),
 rowcount=1.0, cumulative cost=IgniteCost [rowCount=Infinity, cpu=Infinity, 
memory=Infinity, io=Infinity, network=Infinity]
                
rel#107:ReduceSortAggregate.IGNITE.single.[](input=RelSubset#105,group={},EXPR$0=SUM($0),collation=[]),
 rowcount=1.0, cumulative cost=IgniteCost [rowCount=Infinity, cpu=Infinity, 
memory=Infinity, io=Infinity, network=Infinity]
Set#8, type: RecordType(DECIMAL(32767, 0) _ACC0, TINYINT _GROUP_ID)
        rel#95:RelSubset#8.IGNITE.random.[], best=null
                
rel#94:MapHashAggregate.IGNITE.random.[](input=RelSubset#88,group={},EXPR$0=SUM($0)),
 rowcount=1.0, cumulative cost=IgniteCost [rowCount=Infinity, cpu=Infinity, 
memory=Infinity, io=Infinity, network=Infinity]
        rel#96:RelSubset#8.IGNITE.single.[], best=null
                
rel#97:Exchange.IGNITE.single.[](input=RelSubset#95,distribution=single), 
rowcount=1.0, cumulative cost=IgniteCost [rowCount=Infinity, cpu=Infinity, 
memory=Infinity, io=Infinity, network=Infinity]
                
rel#99:MapHashAggregate.IGNITE.single.[](input=RelSubset#92,group={},EXPR$0=SUM($0)),
 rowcount=1.0, cumulative cost=IgniteCost [rowCount=Infinity, cpu=Infinity, 
memory=Infinity, io=Infinity, network=Infinity]
Set#9, type: RecordType(DECIMAL(32767, 0) _ACC0)
        rel#104:RelSubset#9.IGNITE.random.[], best=null
                
rel#103:MapSortAggregate.IGNITE.random.[](input=RelSubset#102,group={},EXPR$0=SUM($0),collation=[]),
 rowcount=1.0, cumulative cost=IgniteCost [rowCount=Infinity, cpu=Infinity, 
memory=Infinity, io=Infinity, network=Infinity]
        rel#105:RelSubset#9.IGNITE.single.[], best=null
                
rel#106:Exchange.IGNITE.single.[](input=RelSubset#104,distribution=single), 
rowcount=1.0, cumulative cost=IgniteCost [rowCount=Infinity, cpu=Infinity, 
memory=Infinity, io=Infinity, network=Infinity]
                
rel#108:MapSortAggregate.IGNITE.single.[](input=RelSubset#92,group={},EXPR$0=SUM($0),collation=[]),
 rowcount=1.0, cumulative cost=IgniteCost [rowCount=Infinity, cpu=Infinity, 
memory=Infinity, io=Infinity, network=Infinity]

Graphviz:
digraph G {
        root [style=filled,label="Root"];
        subgraph cluster0{
                label="Set 0 RecordType(INTEGER EXPR$0)";
                rel1 [label="rel#1:LogicalValues\ntype=RecordType(INTEGER 
EXPR$0),tuples=[{ 1 }]\nrows=1.0, cost=IgniteCost [rowCount=Infinity, 
cpu=Infinity, memory=Infinity, io=Infinity, network=Infinity]",shape=box]
                subset77 [label="rel#77:RelSubset#0.NONE.any.[0]"]
        }
        subgraph cluster1{
                label="Set 1 RecordType(INTEGER EXPR$0)";
                rel78 
[label="rel#78:LogicalTableSpool\ninput=RelSubset#77,readType=LAZY,writeType=LAZY,table=[T]\nrows=1.0,
 cost=IgniteCost [rowCount=Infinity, cpu=Infinity, memory=Infinity, 
io=Infinity, network=Infinity]",shape=box]
                subset79 [label="rel#79:RelSubset#1.NONE.any.[0]"]
        }
        subgraph cluster2{
                label="Set 2 RecordType(INTEGER N)";
                rel2 [label="rel#2:LogicalTableScan\ntable=[T]\nrows=100.0, 
cost=IgniteCost [rowCount=Infinity, cpu=Infinity, memory=Infinity, io=Infinity, 
network=Infinity]",shape=box]
                subset80 [label="rel#80:RelSubset#2.NONE.any.[]"]
        }
        subgraph cluster3{
                label="Set 3 RecordType(INTEGER N)";
                rel81 
[label="rel#81:LogicalFilter\ninput=RelSubset#80,condition=<($0, 
100)\nrows=50.0, cost=IgniteCost [rowCount=Infinity, cpu=Infinity, 
memory=Infinity, io=Infinity, network=Infinity]",shape=box]
                subset82 [label="rel#82:RelSubset#3.NONE.any.[]"]
        }
        subgraph cluster4{
                label="Set 4 RecordType(INTEGER EXPR$0)";
                rel83 
[label="rel#83:LogicalProject\ninput=RelSubset#82,exprs=[+($0, 1)]\nrows=50.0, 
cost=IgniteCost [rowCount=Infinity, cpu=Infinity, memory=Infinity, io=Infinity, 
network=Infinity]",shape=box]
                subset84 [label="rel#84:RelSubset#4.NONE.any.[]"]
        }
        subgraph cluster5{
                label="Set 5 RecordType(INTEGER EXPR$0)";
                rel85 
[label="rel#85:LogicalTableSpool\ninput=RelSubset#84,readType=LAZY,writeType=LAZY,table=[T]\nrows=50.0,
 cost=IgniteCost [rowCount=Infinity, cpu=Infinity, memory=Infinity, 
io=Infinity, network=Infinity]",shape=box]
                subset86 [label="rel#86:RelSubset#5.NONE.any.[]"]
        }
        subgraph cluster6{
                label="Set 6 RecordType(INTEGER EXPR$0)";
                rel87 
[label="rel#87:LogicalRepeatUnion\nleft=RelSubset#79,right=RelSubset#86,all=true\nrows=501.0,
 cost=IgniteCost [rowCount=Infinity, cpu=Infinity, memory=Infinity, 
io=Infinity, network=Infinity]",shape=box]
                subset88 [label="rel#88:RelSubset#6.NONE.any.[]"]
                subset92 [label="rel#92:RelSubset#6.IGNITE.single.[]",color=red]
                subset102 
[label="rel#102:RelSubset#6.IGNITE.random.[]",color=red]
        }
        subgraph cluster7{
                label="Set 7 RecordType(BIGINT EXPR$0)";
                rel89 
[label="rel#89:LogicalAggregate\ninput=RelSubset#88,group={},EXPR$0=SUM($0)\nrows=1.0,
 cost=IgniteCost [rowCount=Infinity, cpu=Infinity, memory=Infinity, 
io=Infinity, network=Infinity]",shape=box]
                rel93 
[label="rel#93:ColocatedHashAggregate\ninput=RelSubset#92,group={},EXPR$0=SUM($0)\nrows=1.0,
 cost=IgniteCost [rowCount=Infinity, cpu=Infinity, memory=Infinity, 
io=Infinity, network=Infinity]",shape=box]
                rel98 
[label="rel#98:ReduceHashAggregate\ninput=RelSubset#96,group={},EXPR$0=SUM($0)\nrows=1.0,
 cost=IgniteCost [rowCount=Infinity, cpu=Infinity, memory=Infinity, 
io=Infinity, network=Infinity]",shape=box]
                rel101 
[label="rel#101:ColocatedSortAggregate\ninput=RelSubset#92,group={},EXPR$0=SUM($0),collation=[]\nrows=1.0,
 cost=IgniteCost [rowCount=Infinity, cpu=Infinity, memory=Infinity, 
io=Infinity, network=Infinity]",shape=box]
                rel107 
[label="rel#107:ReduceSortAggregate\ninput=RelSubset#105,group={},EXPR$0=SUM($0),collation=[]\nrows=1.0,
 cost=IgniteCost [rowCount=Infinity, cpu=Infinity, memory=Infinity, 
io=Infinity, network=Infinity]",shape=box]
                subset90 [label="rel#90:RelSubset#7.NONE.any.[]"]
                subset91 [label="rel#91:RelSubset#7.IGNITE.single.[]"]
        }
        subgraph cluster8{
                label="Set 8 RecordType(DECIMAL(32767, 0) _ACC0, TINYINT 
_GROUP_ID)";
                rel94 
[label="rel#94:MapHashAggregate\ninput=RelSubset#88,group={},EXPR$0=SUM($0)\nrows=1.0,
 cost=IgniteCost [rowCount=Infinity, cpu=Infinity, memory=Infinity, 
io=Infinity, network=Infinity]",shape=box]
                rel97 
[label="rel#97:Exchange\ninput=RelSubset#95,distribution=single\nrows=1.0, 
cost=IgniteCost [rowCount=Infinity, cpu=Infinity, memory=Infinity, io=Infinity, 
network=Infinity]",shape=box]
                rel99 
[label="rel#99:MapHashAggregate\ninput=RelSubset#92,group={},EXPR$0=SUM($0)\nrows=1.0,
 cost=IgniteCost [rowCount=Infinity, cpu=Infinity, memory=Infinity, 
io=Infinity, network=Infinity]",shape=box]
                subset95 [label="rel#95:RelSubset#8.IGNITE.random.[]"]
                subset96 [label="rel#96:RelSubset#8.IGNITE.single.[]"]
        }
        subgraph cluster9{
                label="Set 9 RecordType(DECIMAL(32767, 0) _ACC0)";
                rel103 
[label="rel#103:MapSortAggregate\ninput=RelSubset#102,group={},EXPR$0=SUM($0),collation=[]\nrows=1.0,
 cost=IgniteCost [rowCount=Infinity, cpu=Infinity, memory=Infinity, 
io=Infinity, network=Infinity]",shape=box]
                rel106 
[label="rel#106:Exchange\ninput=RelSubset#104,distribution=single\nrows=1.0, 
cost=IgniteCost [rowCount=Infinity, cpu=Infinity, memory=Infinity, io=Infinity, 
network=Infinity]",shape=box]
                rel108 
[label="rel#108:MapSortAggregate\ninput=RelSubset#92,group={},EXPR$0=SUM($0),collation=[]\nrows=1.0,
 cost=IgniteCost [rowCount=Infinity, cpu=Infinity, memory=Infinity, 
io=Infinity, network=Infinity]",shape=box]
                subset104 [label="rel#104:RelSubset#9.IGNITE.random.[]"]
                subset105 [label="rel#105:RelSubset#9.IGNITE.single.[]"]
        }
        root -> subset91;
        subset77 -> rel1;
        subset79 -> rel78; rel78 -> subset77;
        subset80 -> rel2;
        subset82 -> rel81; rel81 -> subset80;
        subset84 -> rel83; rel83 -> subset82;
        subset86 -> rel85; rel85 -> subset84;
        subset88 -> rel87; rel87 -> subset79[label="0"]; rel87 -> 
subset86[label="1"];
        subset90 -> rel89; rel89 -> subset88;
        subset91 -> rel93; rel93 -> subset92;
        subset91 -> rel98; rel98 -> subset96;
        subset91 -> rel101; rel101 -> subset92;
        subset91 -> rel107; rel107 -> subset105;
        subset95 -> rel94; rel94 -> subset88;
        subset96 -> rel97; rel97 -> subset95;
        subset96 -> rel99; rel99 -> subset92;
        subset104 -> rel103; rel103 -> subset102;
        subset105 -> rel106; rel106 -> subset104;
        subset105 -> rel108; rel108 -> subset92;
}
        at 
org.apache.ignite.internal.lang.SqlExceptionMapperUtil.mapToPublicSqlException(SqlExceptionMapperUtil.java:61)
        at 
org.apache.ignite.internal.sql.engine.prepare.PrepareServiceImpl.lambda$prepareAsync$0(PrepareServiceImpl.java:246)
        ... 7 more
Caused by: org.apache.ignite.lang.IgniteException: IGN-CMN-65535 
TraceId:c2961dbf-64fd-4806-a2d9-20368f8454e5 There are not enough rules to 
produce a node with desired properties: convention=IGNITE, distr=single, 
sort=[].
Missing conversions are LogicalRepeatUnion[convention: NONE -> IGNITE, distr: 
any -> single], LogicalRepeatUnion[convention: NONE -> IGNITE, distr: any -> 
random]
There are 2 empty subsets:
Empty subset 0: rel#92:RelSubset#6.IGNITE.single.[], the relevant part of the 
original plan is as follows
87:LogicalRepeatUnion(all=[true])
  78:LogicalTableSpool(subset=[rel#79:RelSubset#1.NONE.any.[0]], 
readType=[LAZY], writeType=[LAZY], table=[[T]])
    1:LogicalValues(subset=[rel#77:RelSubset#0.NONE.any.[0]], tuples=[[{ 1 }]])
  85:LogicalTableSpool(subset=[rel#86:RelSubset#5.NONE.any.[]], 
readType=[LAZY], writeType=[LAZY], table=[[T]])
    83:LogicalProject(subset=[rel#84:RelSubset#4.NONE.any.[]], EXPR$0=[+($0, 
1)])
      81:LogicalFilter(subset=[rel#82:RelSubset#3.NONE.any.[]], 
condition=[<($0, 100)])
        2:LogicalTableScan(subset=[rel#80:RelSubset#2.NONE.any.[]], table=[[T]])

Empty subset 1: rel#102:RelSubset#6.IGNITE.random.[], the relevant part of the 
original plan is as follows
87:LogicalRepeatUnion(all=[true])
  78:LogicalTableSpool(subset=[rel#79:RelSubset#1.NONE.any.[0]], 
readType=[LAZY], writeType=[LAZY], table=[[T]])
    1:LogicalValues(subset=[rel#77:RelSubset#0.NONE.any.[0]], tuples=[[{ 1 }]])
  85:LogicalTableSpool(subset=[rel#86:RelSubset#5.NONE.any.[]], 
readType=[LAZY], writeType=[LAZY], table=[[T]])
    83:LogicalProject(subset=[rel#84:RelSubset#4.NONE.any.[]], EXPR$0=[+($0, 
1)])
      81:LogicalFilter(subset=[rel#82:RelSubset#3.NONE.any.[]], 
condition=[<($0, 100)])
        2:LogicalTableScan(subset=[rel#80:RelSubset#2.NONE.any.[]], table=[[T]])

Root: rel#91:RelSubset#7.IGNITE.single.[]
Original rel:
LogicalAggregate(subset=[rel#91:RelSubset#7.IGNITE.single.[]], group=[{}], 
EXPR$0=[SUM($0)]): rowcount = 1.0, cumulative cost = IgniteCost 
[rowCount=Infinity, cpu=Infinity, memory=Infinity, io=Infinity, 
network=Infinity], id = 89
  LogicalRepeatUnion(subset=[rel#88:RelSubset#6.NONE.any.[]], all=[true]): 
rowcount = 501.0, cumulative cost = IgniteCost [rowCount=Infinity, 
cpu=Infinity, memory=Infinity, io=Infinity, network=Infinity], id = 87
    LogicalTableSpool(subset=[rel#79:RelSubset#1.NONE.any.[0]], 
readType=[LAZY], writeType=[LAZY], table=[[T]]): rowcount = 1.0, cumulative 
cost = IgniteCost [rowCount=Infinity, cpu=Infinity, memory=Infinity, 
io=Infinity, network=Infinity], id = 78
      LogicalValues(subset=[rel#77:RelSubset#0.NONE.any.[0]], tuples=[[{ 1 
}]]): rowcount = 1.0, cumulative cost = IgniteCost [rowCount=Infinity, 
cpu=Infinity, memory=Infinity, io=Infinity, network=Infinity], id = 1
    LogicalTableSpool(subset=[rel#86:RelSubset#5.NONE.any.[]], readType=[LAZY], 
writeType=[LAZY], table=[[T]]): rowcount = 50.0, cumulative cost = IgniteCost 
[rowCount=Infinity, cpu=Infinity, memory=Infinity, io=Infinity, 
network=Infinity], id = 85
      LogicalProject(subset=[rel#84:RelSubset#4.NONE.any.[]], EXPR$0=[+($0, 
1)]): rowcount = 50.0, cumulative cost = IgniteCost [rowCount=Infinity, 
cpu=Infinity, memory=Infinity, io=Infinity, network=Infinity], id = 83
        LogicalFilter(subset=[rel#82:RelSubset#3.NONE.any.[]], condition=[<($0, 
100)]): rowcount = 50.0, cumulative cost = IgniteCost [rowCount=Infinity, 
cpu=Infinity, memory=Infinity, io=Infinity, network=Infinity], id = 81
          LogicalTableScan(subset=[rel#80:RelSubset#2.NONE.any.[]], 
table=[[T]]): rowcount = 100.0, cumulative cost = IgniteCost 
[rowCount=Infinity, cpu=Infinity, memory=Infinity, io=Infinity, 
network=Infinity], id = 2

Sets:
Set#0, type: RecordType(INTEGER EXPR$0)
        rel#77:RelSubset#0.NONE.any.[0], best=null
                rel#1:LogicalValues.NONE.any.[0](type=RecordType(INTEGER 
EXPR$0),tuples=[{ 1 }]), rowcount=1.0, cumulative cost=IgniteCost 
[rowCount=Infinity, cpu=Infinity, memory=Infinity, io=Infinity, 
network=Infinity]
Set#1, type: RecordType(INTEGER EXPR$0)
        rel#79:RelSubset#1.NONE.any.[0], best=null
                
rel#78:LogicalTableSpool.NONE.any.[0](input=RelSubset#77,readType=LAZY,writeType=LAZY,table=[T]),
 rowcount=1.0, cumulative cost=IgniteCost [rowCount=Infinity, cpu=Infinity, 
memory=Infinity, io=Infinity, network=Infinity]
Set#2, type: RecordType(INTEGER N)
        rel#80:RelSubset#2.NONE.any.[], best=null
                rel#2:LogicalTableScan.NONE.any.[](table=[T]), rowcount=100.0, 
cumulative cost=IgniteCost [rowCount=Infinity, cpu=Infinity, memory=Infinity, 
io=Infinity, network=Infinity]
Set#3, type: RecordType(INTEGER N)
        rel#82:RelSubset#3.NONE.any.[], best=null
                
rel#81:LogicalFilter.NONE.any.[](input=RelSubset#80,condition=<($0, 100)), 
rowcount=50.0, cumulative cost=IgniteCost [rowCount=Infinity, cpu=Infinity, 
memory=Infinity, io=Infinity, network=Infinity]
Set#4, type: RecordType(INTEGER EXPR$0)
        rel#84:RelSubset#4.NONE.any.[], best=null
                
rel#83:LogicalProject.NONE.any.[](input=RelSubset#82,exprs=[+($0, 1)]), 
rowcount=50.0, cumulative cost=IgniteCost [rowCount=Infinity, cpu=Infinity, 
memory=Infinity, io=Infinity, network=Infinity]
Set#5, type: RecordType(INTEGER EXPR$0)
        rel#86:RelSubset#5.NONE.any.[], best=null
                
rel#85:LogicalTableSpool.NONE.any.[](input=RelSubset#84,readType=LAZY,writeType=LAZY,table=[T]),
 rowcount=50.0, cumulative cost=IgniteCost [rowCount=Infinity, cpu=Infinity, 
memory=Infinity, io=Infinity, network=Infinity]
Set#6, type: RecordType(INTEGER EXPR$0)
        rel#88:RelSubset#6.NONE.any.[], best=null
                
rel#87:LogicalRepeatUnion.NONE.any.[](left=RelSubset#79,right=RelSubset#86,all=true),
 rowcount=501.0, cumulative cost=IgniteCost [rowCount=Infinity, cpu=Infinity, 
memory=Infinity, io=Infinity, network=Infinity]
        rel#92:RelSubset#6.IGNITE.single.[], best=null
        rel#102:RelSubset#6.IGNITE.random.[], best=null
Set#7, type: RecordType(BIGINT EXPR$0)
        rel#90:RelSubset#7.NONE.any.[], best=null
                
rel#89:LogicalAggregate.NONE.any.[](input=RelSubset#88,group={},EXPR$0=SUM($0)),
 rowcount=1.0, cumulative cost=IgniteCost [rowCount=Infinity, cpu=Infinity, 
memory=Infinity, io=Infinity, network=Infinity]
        rel#91:RelSubset#7.IGNITE.single.[], best=null
                
rel#93:ColocatedHashAggregate.IGNITE.single.[](input=RelSubset#92,group={},EXPR$0=SUM($0)),
 rowcount=1.0, cumulative cost=IgniteCost [rowCount=Infinity, cpu=Infinity, 
memory=Infinity, io=Infinity, network=Infinity]
                
rel#98:ReduceHashAggregate.IGNITE.single.[](input=RelSubset#96,group={},EXPR$0=SUM($0)),
 rowcount=1.0, cumulative cost=IgniteCost [rowCount=Infinity, cpu=Infinity, 
memory=Infinity, io=Infinity, network=Infinity]
                
rel#101:ColocatedSortAggregate.IGNITE.single.[](input=RelSubset#92,group={},EXPR$0=SUM($0),collation=[]),
 rowcount=1.0, cumulative cost=IgniteCost [rowCount=Infinity, cpu=Infinity, 
memory=Infinity, io=Infinity, network=Infinity]
                
rel#107:ReduceSortAggregate.IGNITE.single.[](input=RelSubset#105,group={},EXPR$0=SUM($0),collation=[]),
 rowcount=1.0, cumulative cost=IgniteCost [rowCount=Infinity, cpu=Infinity, 
memory=Infinity, io=Infinity, network=Infinity]
Set#8, type: RecordType(DECIMAL(32767, 0) _ACC0, TINYINT _GROUP_ID)
        rel#95:RelSubset#8.IGNITE.random.[], best=null
                
rel#94:MapHashAggregate.IGNITE.random.[](input=RelSubset#88,group={},EXPR$0=SUM($0)),
 rowcount=1.0, cumulative cost=IgniteCost [rowCount=Infinity, cpu=Infinity, 
memory=Infinity, io=Infinity, network=Infinity]
        rel#96:RelSubset#8.IGNITE.single.[], best=null
                
rel#97:Exchange.IGNITE.single.[](input=RelSubset#95,distribution=single), 
rowcount=1.0, cumulative cost=IgniteCost [rowCount=Infinity, cpu=Infinity, 
memory=Infinity, io=Infinity, network=Infinity]
                
rel#99:MapHashAggregate.IGNITE.single.[](input=RelSubset#92,group={},EXPR$0=SUM($0)),
 rowcount=1.0, cumulative cost=IgniteCost [rowCount=Infinity, cpu=Infinity, 
memory=Infinity, io=Infinity, network=Infinity]
Set#9, type: RecordType(DECIMAL(32767, 0) _ACC0)
        rel#104:RelSubset#9.IGNITE.random.[], best=null
                
rel#103:MapSortAggregate.IGNITE.random.[](input=RelSubset#102,group={},EXPR$0=SUM($0),collation=[]),
 rowcount=1.0, cumulative cost=IgniteCost [rowCount=Infinity, cpu=Infinity, 
memory=Infinity, io=Infinity, network=Infinity]
        rel#105:RelSubset#9.IGNITE.single.[], best=null
                
rel#106:Exchange.IGNITE.single.[](input=RelSubset#104,distribution=single), 
rowcount=1.0, cumulative cost=IgniteCost [rowCount=Infinity, cpu=Infinity, 
memory=Infinity, io=Infinity, network=Infinity]
                
rel#108:MapSortAggregate.IGNITE.single.[](input=RelSubset#92,group={},EXPR$0=SUM($0),collation=[]),
 rowcount=1.0, cumulative cost=IgniteCost [rowCount=Infinity, cpu=Infinity, 
memory=Infinity, io=Infinity, network=Infinity]

Graphviz:
digraph G {
        root [style=filled,label="Root"];
        subgraph cluster0{
                label="Set 0 RecordType(INTEGER EXPR$0)";
                rel1 [label="rel#1:LogicalValues\ntype=RecordType(INTEGER 
EXPR$0),tuples=[{ 1 }]\nrows=1.0, cost=IgniteCost [rowCount=Infinity, 
cpu=Infinity, memory=Infinity, io=Infinity, network=Infinity]",shape=box]
                subset77 [label="rel#77:RelSubset#0.NONE.any.[0]"]
        }
        subgraph cluster1{
                label="Set 1 RecordType(INTEGER EXPR$0)";
                rel78 
[label="rel#78:LogicalTableSpool\ninput=RelSubset#77,readType=LAZY,writeType=LAZY,table=[T]\nrows=1.0,
 cost=IgniteCost [rowCount=Infinity, cpu=Infinity, memory=Infinity, 
io=Infinity, network=Infinity]",shape=box]
                subset79 [label="rel#79:RelSubset#1.NONE.any.[0]"]
        }
        subgraph cluster2{
                label="Set 2 RecordType(INTEGER N)";
                rel2 [label="rel#2:LogicalTableScan\ntable=[T]\nrows=100.0, 
cost=IgniteCost [rowCount=Infinity, cpu=Infinity, memory=Infinity, io=Infinity, 
network=Infinity]",shape=box]
                subset80 [label="rel#80:RelSubset#2.NONE.any.[]"]
        }
        subgraph cluster3{
                label="Set 3 RecordType(INTEGER N)";
                rel81 
[label="rel#81:LogicalFilter\ninput=RelSubset#80,condition=<($0, 
100)\nrows=50.0, cost=IgniteCost [rowCount=Infinity, cpu=Infinity, 
memory=Infinity, io=Infinity, network=Infinity]",shape=box]
                subset82 [label="rel#82:RelSubset#3.NONE.any.[]"]
        }
        subgraph cluster4{
                label="Set 4 RecordType(INTEGER EXPR$0)";
                rel83 
[label="rel#83:LogicalProject\ninput=RelSubset#82,exprs=[+($0, 1)]\nrows=50.0, 
cost=IgniteCost [rowCount=Infinity, cpu=Infinity, memory=Infinity, io=Infinity, 
network=Infinity]",shape=box]
                subset84 [label="rel#84:RelSubset#4.NONE.any.[]"]
        }
        subgraph cluster5{
                label="Set 5 RecordType(INTEGER EXPR$0)";
                rel85 
[label="rel#85:LogicalTableSpool\ninput=RelSubset#84,readType=LAZY,writeType=LAZY,table=[T]\nrows=50.0,
 cost=IgniteCost [rowCount=Infinity, cpu=Infinity, memory=Infinity, 
io=Infinity, network=Infinity]",shape=box]
                subset86 [label="rel#86:RelSubset#5.NONE.any.[]"]
        }
        subgraph cluster6{
                label="Set 6 RecordType(INTEGER EXPR$0)";
                rel87 
[label="rel#87:LogicalRepeatUnion\nleft=RelSubset#79,right=RelSubset#86,all=true\nrows=501.0,
 cost=IgniteCost [rowCount=Infinity, cpu=Infinity, memory=Infinity, 
io=Infinity, network=Infinity]",shape=box]
                subset88 [label="rel#88:RelSubset#6.NONE.any.[]"]
                subset92 [label="rel#92:RelSubset#6.IGNITE.single.[]",color=red]
                subset102 
[label="rel#102:RelSubset#6.IGNITE.random.[]",color=red]
        }
        subgraph cluster7{
                label="Set 7 RecordType(BIGINT EXPR$0)";
                rel89 
[label="rel#89:LogicalAggregate\ninput=RelSubset#88,group={},EXPR$0=SUM($0)\nrows=1.0,
 cost=IgniteCost [rowCount=Infinity, cpu=Infinity, memory=Infinity, 
io=Infinity, network=Infinity]",shape=box]
                rel93 
[label="rel#93:ColocatedHashAggregate\ninput=RelSubset#92,group={},EXPR$0=SUM($0)\nrows=1.0,
 cost=IgniteCost [rowCount=Infinity, cpu=Infinity, memory=Infinity, 
io=Infinity, network=Infinity]",shape=box]
                rel98 
[label="rel#98:ReduceHashAggregate\ninput=RelSubset#96,group={},EXPR$0=SUM($0)\nrows=1.0,
 cost=IgniteCost [rowCount=Infinity, cpu=Infinity, memory=Infinity, 
io=Infinity, network=Infinity]",shape=box]
                rel101 
[label="rel#101:ColocatedSortAggregate\ninput=RelSubset#92,group={},EXPR$0=SUM($0),collation=[]\nrows=1.0,
 cost=IgniteCost [rowCount=Infinity, cpu=Infinity, memory=Infinity, 
io=Infinity, network=Infinity]",shape=box]
                rel107 
[label="rel#107:ReduceSortAggregate\ninput=RelSubset#105,group={},EXPR$0=SUM($0),collation=[]\nrows=1.0,
 cost=IgniteCost [rowCount=Infinity, cpu=Infinity, memory=Infinity, 
io=Infinity, network=Infinity]",shape=box]
                subset90 [label="rel#90:RelSubset#7.NONE.any.[]"]
                subset91 [label="rel#91:RelSubset#7.IGNITE.single.[]"]
        }
        subgraph cluster8{
                label="Set 8 RecordType(DECIMAL(32767, 0) _ACC0, TINYINT 
_GROUP_ID)";
                rel94 
[label="rel#94:MapHashAggregate\ninput=RelSubset#88,group={},EXPR$0=SUM($0)\nrows=1.0,
 cost=IgniteCost [rowCount=Infinity, cpu=Infinity, memory=Infinity, 
io=Infinity, network=Infinity]",shape=box]
                rel97 
[label="rel#97:Exchange\ninput=RelSubset#95,distribution=single\nrows=1.0, 
cost=IgniteCost [rowCount=Infinity, cpu=Infinity, memory=Infinity, io=Infinity, 
network=Infinity]",shape=box]
                rel99 
[label="rel#99:MapHashAggregate\ninput=RelSubset#92,group={},EXPR$0=SUM($0)\nrows=1.0,
 cost=IgniteCost [rowCount=Infinity, cpu=Infinity, memory=Infinity, 
io=Infinity, network=Infinity]",shape=box]
                subset95 [label="rel#95:RelSubset#8.IGNITE.random.[]"]
                subset96 [label="rel#96:RelSubset#8.IGNITE.single.[]"]
        }
        subgraph cluster9{
                label="Set 9 RecordType(DECIMAL(32767, 0) _ACC0)";
                rel103 
[label="rel#103:MapSortAggregate\ninput=RelSubset#102,group={},EXPR$0=SUM($0),collation=[]\nrows=1.0,
 cost=IgniteCost [rowCount=Infinity, cpu=Infinity, memory=Infinity, 
io=Infinity, network=Infinity]",shape=box]
                rel106 
[label="rel#106:Exchange\ninput=RelSubset#104,distribution=single\nrows=1.0, 
cost=IgniteCost [rowCount=Infinity, cpu=Infinity, memory=Infinity, io=Infinity, 
network=Infinity]",shape=box]
                rel108 
[label="rel#108:MapSortAggregate\ninput=RelSubset#92,group={},EXPR$0=SUM($0),collation=[]\nrows=1.0,
 cost=IgniteCost [rowCount=Infinity, cpu=Infinity, memory=Infinity, 
io=Infinity, network=Infinity]",shape=box]
                subset104 [label="rel#104:RelSubset#9.IGNITE.random.[]"]
                subset105 [label="rel#105:RelSubset#9.IGNITE.single.[]"]
        }
        root -> subset91;
        subset77 -> rel1;
        subset79 -> rel78; rel78 -> subset77;
        subset80 -> rel2;
        subset82 -> rel81; rel81 -> subset80;
        subset84 -> rel83; rel83 -> subset82;
        subset86 -> rel85; rel85 -> subset84;
        subset88 -> rel87; rel87 -> subset79[label="0"]; rel87 -> 
subset86[label="1"];
        subset90 -> rel89; rel89 -> subset88;
        subset91 -> rel93; rel93 -> subset92;
        subset91 -> rel98; rel98 -> subset96;
        subset91 -> rel101; rel101 -> subset92;
        subset91 -> rel107; rel107 -> subset105;
        subset95 -> rel94; rel94 -> subset88;
        subset96 -> rel97; rel97 -> subset95;
        subset96 -> rel99; rel99 -> subset92;
        subset104 -> rel103; rel103 -> subset102;
        subset105 -> rel106; rel106 -> subset104;
        subset105 -> rel108; rel108 -> subset92;
}
        at 
org.apache.ignite.internal.lang.IgniteExceptionMapperUtil.mapToPublicException(IgniteExceptionMapperUtil.java:118)
        at 
org.apache.ignite.internal.lang.SqlExceptionMapperUtil.mapToPublicSqlException(SqlExceptionMapperUtil.java:51)
        ... 8 more
Caused by: org.apache.calcite.plan.RelOptPlanner$CannotPlanException: There are 
not enough rules to produce a node with desired properties: convention=IGNITE, 
distr=single, sort=[].
Missing conversions are LogicalRepeatUnion[convention: NONE -> IGNITE, distr: 
any -> single], LogicalRepeatUnion[convention: NONE -> IGNITE, distr: any -> 
random]
There are 2 empty subsets:
Empty subset 0: rel#92:RelSubset#6.IGNITE.single.[], the relevant part of the 
original plan is as follows
87:LogicalRepeatUnion(all=[true])
  78:LogicalTableSpool(subset=[rel#79:RelSubset#1.NONE.any.[0]], 
readType=[LAZY], writeType=[LAZY], table=[[T]])
    1:LogicalValues(subset=[rel#77:RelSubset#0.NONE.any.[0]], tuples=[[{ 1 }]])
  85:LogicalTableSpool(subset=[rel#86:RelSubset#5.NONE.any.[]], 
readType=[LAZY], writeType=[LAZY], table=[[T]])
    83:LogicalProject(subset=[rel#84:RelSubset#4.NONE.any.[]], EXPR$0=[+($0, 
1)])
      81:LogicalFilter(subset=[rel#82:RelSubset#3.NONE.any.[]], 
condition=[<($0, 100)])
        2:LogicalTableScan(subset=[rel#80:RelSubset#2.NONE.any.[]], table=[[T]])

Empty subset 1: rel#102:RelSubset#6.IGNITE.random.[], the relevant part of the 
original plan is as follows
87:LogicalRepeatUnion(all=[true])
  78:LogicalTableSpool(subset=[rel#79:RelSubset#1.NONE.any.[0]], 
readType=[LAZY], writeType=[LAZY], table=[[T]])
    1:LogicalValues(subset=[rel#77:RelSubset#0.NONE.any.[0]], tuples=[[{ 1 }]])
  85:LogicalTableSpool(subset=[rel#86:RelSubset#5.NONE.any.[]], 
readType=[LAZY], writeType=[LAZY], table=[[T]])
    83:LogicalProject(subset=[rel#84:RelSubset#4.NONE.any.[]], EXPR$0=[+($0, 
1)])
      81:LogicalFilter(subset=[rel#82:RelSubset#3.NONE.any.[]], 
condition=[<($0, 100)])
        2:LogicalTableScan(subset=[rel#80:RelSubset#2.NONE.any.[]], table=[[T]])

Root: rel#91:RelSubset#7.IGNITE.single.[]
Original rel:
LogicalAggregate(subset=[rel#91:RelSubset#7.IGNITE.single.[]], group=[{}], 
EXPR$0=[SUM($0)]): rowcount = 1.0, cumulative cost = IgniteCost 
[rowCount=Infinity, cpu=Infinity, memory=Infinity, io=Infinity, 
network=Infinity], id = 89
  LogicalRepeatUnion(subset=[rel#88:RelSubset#6.NONE.any.[]], all=[true]): 
rowcount = 501.0, cumulative cost = IgniteCost [rowCount=Infinity, 
cpu=Infinity, memory=Infinity, io=Infinity, network=Infinity], id = 87
    LogicalTableSpool(subset=[rel#79:RelSubset#1.NONE.any.[0]], 
readType=[LAZY], writeType=[LAZY], table=[[T]]): rowcount = 1.0, cumulative 
cost = IgniteCost [rowCount=Infinity, cpu=Infinity, memory=Infinity, 
io=Infinity, network=Infinity], id = 78
      LogicalValues(subset=[rel#77:RelSubset#0.NONE.any.[0]], tuples=[[{ 1 
}]]): rowcount = 1.0, cumulative cost = IgniteCost [rowCount=Infinity, 
cpu=Infinity, memory=Infinity, io=Infinity, network=Infinity], id = 1
    LogicalTableSpool(subset=[rel#86:RelSubset#5.NONE.any.[]], readType=[LAZY], 
writeType=[LAZY], table=[[T]]): rowcount = 50.0, cumulative cost = IgniteCost 
[rowCount=Infinity, cpu=Infinity, memory=Infinity, io=Infinity, 
network=Infinity], id = 85
      LogicalProject(subset=[rel#84:RelSubset#4.NONE.any.[]], EXPR$0=[+($0, 
1)]): rowcount = 50.0, cumulative cost = IgniteCost [rowCount=Infinity, 
cpu=Infinity, memory=Infinity, io=Infinity, network=Infinity], id = 83
        LogicalFilter(subset=[rel#82:RelSubset#3.NONE.any.[]], condition=[<($0, 
100)]): rowcount = 50.0, cumulative cost = IgniteCost [rowCount=Infinity, 
cpu=Infinity, memory=Infinity, io=Infinity, network=Infinity], id = 81
          LogicalTableScan(subset=[rel#80:RelSubset#2.NONE.any.[]], 
table=[[T]]): rowcount = 100.0, cumulative cost = IgniteCost 
[rowCount=Infinity, cpu=Infinity, memory=Infinity, io=Infinity, 
network=Infinity], id = 2

Sets:
Set#0, type: RecordType(INTEGER EXPR$0)
        rel#77:RelSubset#0.NONE.any.[0], best=null
                rel#1:LogicalValues.NONE.any.[0](type=RecordType(INTEGER 
EXPR$0),tuples=[{ 1 }]), rowcount=1.0, cumulative cost=IgniteCost 
[rowCount=Infinity, cpu=Infinity, memory=Infinity, io=Infinity, 
network=Infinity]
Set#1, type: RecordType(INTEGER EXPR$0)
        rel#79:RelSubset#1.NONE.any.[0], best=null
                
rel#78:LogicalTableSpool.NONE.any.[0](input=RelSubset#77,readType=LAZY,writeType=LAZY,table=[T]),
 rowcount=1.0, cumulative cost=IgniteCost [rowCount=Infinity, cpu=Infinity, 
memory=Infinity, io=Infinity, network=Infinity]
Set#2, type: RecordType(INTEGER N)
        rel#80:RelSubset#2.NONE.any.[], best=null
                rel#2:LogicalTableScan.NONE.any.[](table=[T]), rowcount=100.0, 
cumulative cost=IgniteCost [rowCount=Infinity, cpu=Infinity, memory=Infinity, 
io=Infinity, network=Infinity]
Set#3, type: RecordType(INTEGER N)
        rel#82:RelSubset#3.NONE.any.[], best=null
                
rel#81:LogicalFilter.NONE.any.[](input=RelSubset#80,condition=<($0, 100)), 
rowcount=50.0, cumulative cost=IgniteCost [rowCount=Infinity, cpu=Infinity, 
memory=Infinity, io=Infinity, network=Infinity]
Set#4, type: RecordType(INTEGER EXPR$0)
        rel#84:RelSubset#4.NONE.any.[], best=null
                
rel#83:LogicalProject.NONE.any.[](input=RelSubset#82,exprs=[+($0, 1)]), 
rowcount=50.0, cumulative cost=IgniteCost [rowCount=Infinity, cpu=Infinity, 
memory=Infinity, io=Infinity, network=Infinity]
Set#5, type: RecordType(INTEGER EXPR$0)
        rel#86:RelSubset#5.NONE.any.[], best=null
                
rel#85:LogicalTableSpool.NONE.any.[](input=RelSubset#84,readType=LAZY,writeType=LAZY,table=[T]),
 rowcount=50.0, cumulative cost=IgniteCost [rowCount=Infinity, cpu=Infinity, 
memory=Infinity, io=Infinity, network=Infinity]
Set#6, type: RecordType(INTEGER EXPR$0)
        rel#88:RelSubset#6.NONE.any.[], best=null
                
rel#87:LogicalRepeatUnion.NONE.any.[](left=RelSubset#79,right=RelSubset#86,all=true),
 rowcount=501.0, cumulative cost=IgniteCost [rowCount=Infinity, cpu=Infinity, 
memory=Infinity, io=Infinity, network=Infinity]
        rel#92:RelSubset#6.IGNITE.single.[], best=null
        rel#102:RelSubset#6.IGNITE.random.[], best=null
Set#7, type: RecordType(BIGINT EXPR$0)
        rel#90:RelSubset#7.NONE.any.[], best=null
                
rel#89:LogicalAggregate.NONE.any.[](input=RelSubset#88,group={},EXPR$0=SUM($0)),
 rowcount=1.0, cumulative cost=IgniteCost [rowCount=Infinity, cpu=Infinity, 
memory=Infinity, io=Infinity, network=Infinity]
        rel#91:RelSubset#7.IGNITE.single.[], best=null
                
rel#93:ColocatedHashAggregate.IGNITE.single.[](input=RelSubset#92,group={},EXPR$0=SUM($0)),
 rowcount=1.0, cumulative cost=IgniteCost [rowCount=Infinity, cpu=Infinity, 
memory=Infinity, io=Infinity, network=Infinity]
                
rel#98:ReduceHashAggregate.IGNITE.single.[](input=RelSubset#96,group={},EXPR$0=SUM($0)),
 rowcount=1.0, cumulative cost=IgniteCost [rowCount=Infinity, cpu=Infinity, 
memory=Infinity, io=Infinity, network=Infinity]
                
rel#101:ColocatedSortAggregate.IGNITE.single.[](input=RelSubset#92,group={},EXPR$0=SUM($0),collation=[]),
 rowcount=1.0, cumulative cost=IgniteCost [rowCount=Infinity, cpu=Infinity, 
memory=Infinity, io=Infinity, network=Infinity]
                
rel#107:ReduceSortAggregate.IGNITE.single.[](input=RelSubset#105,group={},EXPR$0=SUM($0),collation=[]),
 rowcount=1.0, cumulative cost=IgniteCost [rowCount=Infinity, cpu=Infinity, 
memory=Infinity, io=Infinity, network=Infinity]
Set#8, type: RecordType(DECIMAL(32767, 0) _ACC0, TINYINT _GROUP_ID)
        rel#95:RelSubset#8.IGNITE.random.[], best=null
                
rel#94:MapHashAggregate.IGNITE.random.[](input=RelSubset#88,group={},EXPR$0=SUM($0)),
 rowcount=1.0, cumulative cost=IgniteCost [rowCount=Infinity, cpu=Infinity, 
memory=Infinity, io=Infinity, network=Infinity]
        rel#96:RelSubset#8.IGNITE.single.[], best=null
                
rel#97:Exchange.IGNITE.single.[](input=RelSubset#95,distribution=single), 
rowcount=1.0, cumulative cost=IgniteCost [rowCount=Infinity, cpu=Infinity, 
memory=Infinity, io=Infinity, network=Infinity]
                
rel#99:MapHashAggregate.IGNITE.single.[](input=RelSubset#92,group={},EXPR$0=SUM($0)),
 rowcount=1.0, cumulative cost=IgniteCost [rowCount=Infinity, cpu=Infinity, 
memory=Infinity, io=Infinity, network=Infinity]
Set#9, type: RecordType(DECIMAL(32767, 0) _ACC0)
        rel#104:RelSubset#9.IGNITE.random.[], best=null
                
rel#103:MapSortAggregate.IGNITE.random.[](input=RelSubset#102,group={},EXPR$0=SUM($0),collation=[]),
 rowcount=1.0, cumulative cost=IgniteCost [rowCount=Infinity, cpu=Infinity, 
memory=Infinity, io=Infinity, network=Infinity]
        rel#105:RelSubset#9.IGNITE.single.[], best=null
                
rel#106:Exchange.IGNITE.single.[](input=RelSubset#104,distribution=single), 
rowcount=1.0, cumulative cost=IgniteCost [rowCount=Infinity, cpu=Infinity, 
memory=Infinity, io=Infinity, network=Infinity]
                
rel#108:MapSortAggregate.IGNITE.single.[](input=RelSubset#92,group={},EXPR$0=SUM($0),collation=[]),
 rowcount=1.0, cumulative cost=IgniteCost [rowCount=Infinity, cpu=Infinity, 
memory=Infinity, io=Infinity, network=Infinity]

Graphviz:
digraph G {
        root [style=filled,label="Root"];
        subgraph cluster0{
                label="Set 0 RecordType(INTEGER EXPR$0)";
                rel1 [label="rel#1:LogicalValues\ntype=RecordType(INTEGER 
EXPR$0),tuples=[{ 1 }]\nrows=1.0, cost=IgniteCost [rowCount=Infinity, 
cpu=Infinity, memory=Infinity, io=Infinity, network=Infinity]",shape=box]
                subset77 [label="rel#77:RelSubset#0.NONE.any.[0]"]
        }
        subgraph cluster1{
                label="Set 1 RecordType(INTEGER EXPR$0)";
                rel78 
[label="rel#78:LogicalTableSpool\ninput=RelSubset#77,readType=LAZY,writeType=LAZY,table=[T]\nrows=1.0,
 cost=IgniteCost [rowCount=Infinity, cpu=Infinity, memory=Infinity, 
io=Infinity, network=Infinity]",shape=box]
                subset79 [label="rel#79:RelSubset#1.NONE.any.[0]"]
        }
        subgraph cluster2{
                label="Set 2 RecordType(INTEGER N)";
                rel2 [label="rel#2:LogicalTableScan\ntable=[T]\nrows=100.0, 
cost=IgniteCost [rowCount=Infinity, cpu=Infinity, memory=Infinity, io=Infinity, 
network=Infinity]",shape=box]
                subset80 [label="rel#80:RelSubset#2.NONE.any.[]"]
        }
        subgraph cluster3{
                label="Set 3 RecordType(INTEGER N)";
                rel81 
[label="rel#81:LogicalFilter\ninput=RelSubset#80,condition=<($0, 
100)\nrows=50.0, cost=IgniteCost [rowCount=Infinity, cpu=Infinity, 
memory=Infinity, io=Infinity, network=Infinity]",shape=box]
                subset82 [label="rel#82:RelSubset#3.NONE.any.[]"]
        }
        subgraph cluster4{
                label="Set 4 RecordType(INTEGER EXPR$0)";
                rel83 
[label="rel#83:LogicalProject\ninput=RelSubset#82,exprs=[+($0, 1)]\nrows=50.0, 
cost=IgniteCost [rowCount=Infinity, cpu=Infinity, memory=Infinity, io=Infinity, 
network=Infinity]",shape=box]
                subset84 [label="rel#84:RelSubset#4.NONE.any.[]"]
        }
        subgraph cluster5{
                label="Set 5 RecordType(INTEGER EXPR$0)";
                rel85 
[label="rel#85:LogicalTableSpool\ninput=RelSubset#84,readType=LAZY,writeType=LAZY,table=[T]\nrows=50.0,
 cost=IgniteCost [rowCount=Infinity, cpu=Infinity, memory=Infinity, 
io=Infinity, network=Infinity]",shape=box]
                subset86 [label="rel#86:RelSubset#5.NONE.any.[]"]
        }
        subgraph cluster6{
                label="Set 6 RecordType(INTEGER EXPR$0)";
                rel87 
[label="rel#87:LogicalRepeatUnion\nleft=RelSubset#79,right=RelSubset#86,all=true\nrows=501.0,
 cost=IgniteCost [rowCount=Infinity, cpu=Infinity, memory=Infinity, 
io=Infinity, network=Infinity]",shape=box]
                subset88 [label="rel#88:RelSubset#6.NONE.any.[]"]
                subset92 [label="rel#92:RelSubset#6.IGNITE.single.[]",color=red]
                subset102 
[label="rel#102:RelSubset#6.IGNITE.random.[]",color=red]
        }
        subgraph cluster7{
                label="Set 7 RecordType(BIGINT EXPR$0)";
                rel89 
[label="rel#89:LogicalAggregate\ninput=RelSubset#88,group={},EXPR$0=SUM($0)\nrows=1.0,
 cost=IgniteCost [rowCount=Infinity, cpu=Infinity, memory=Infinity, 
io=Infinity, network=Infinity]",shape=box]
                rel93 
[label="rel#93:ColocatedHashAggregate\ninput=RelSubset#92,group={},EXPR$0=SUM($0)\nrows=1.0,
 cost=IgniteCost [rowCount=Infinity, cpu=Infinity, memory=Infinity, 
io=Infinity, network=Infinity]",shape=box]
                rel98 
[label="rel#98:ReduceHashAggregate\ninput=RelSubset#96,group={},EXPR$0=SUM($0)\nrows=1.0,
 cost=IgniteCost [rowCount=Infinity, cpu=Infinity, memory=Infinity, 
io=Infinity, network=Infinity]",shape=box]
                rel101 
[label="rel#101:ColocatedSortAggregate\ninput=RelSubset#92,group={},EXPR$0=SUM($0),collation=[]\nrows=1.0,
 cost=IgniteCost [rowCount=Infinity, cpu=Infinity, memory=Infinity, 
io=Infinity, network=Infinity]",shape=box]
                rel107 
[label="rel#107:ReduceSortAggregate\ninput=RelSubset#105,group={},EXPR$0=SUM($0),collation=[]\nrows=1.0,
 cost=IgniteCost [rowCount=Infinity, cpu=Infinity, memory=Infinity, 
io=Infinity, network=Infinity]",shape=box]
                subset90 [label="rel#90:RelSubset#7.NONE.any.[]"]
                subset91 [label="rel#91:RelSubset#7.IGNITE.single.[]"]
        }
        subgraph cluster8{
                label="Set 8 RecordType(DECIMAL(32767, 0) _ACC0, TINYINT 
_GROUP_ID)";
                rel94 
[label="rel#94:MapHashAggregate\ninput=RelSubset#88,group={},EXPR$0=SUM($0)\nrows=1.0,
 cost=IgniteCost [rowCount=Infinity, cpu=Infinity, memory=Infinity, 
io=Infinity, network=Infinity]",shape=box]
                rel97 
[label="rel#97:Exchange\ninput=RelSubset#95,distribution=single\nrows=1.0, 
cost=IgniteCost [rowCount=Infinity, cpu=Infinity, memory=Infinity, io=Infinity, 
network=Infinity]",shape=box]
                rel99 
[label="rel#99:MapHashAggregate\ninput=RelSubset#92,group={},EXPR$0=SUM($0)\nrows=1.0,
 cost=IgniteCost [rowCount=Infinity, cpu=Infinity, memory=Infinity, 
io=Infinity, network=Infinity]",shape=box]
                subset95 [label="rel#95:RelSubset#8.IGNITE.random.[]"]
                subset96 [label="rel#96:RelSubset#8.IGNITE.single.[]"]
        }
        subgraph cluster9{
                label="Set 9 RecordType(DECIMAL(32767, 0) _ACC0)";
                rel103 
[label="rel#103:MapSortAggregate\ninput=RelSubset#102,group={},EXPR$0=SUM($0),collation=[]\nrows=1.0,
 cost=IgniteCost [rowCount=Infinity, cpu=Infinity, memory=Infinity, 
io=Infinity, network=Infinity]",shape=box]
                rel106 
[label="rel#106:Exchange\ninput=RelSubset#104,distribution=single\nrows=1.0, 
cost=IgniteCost [rowCount=Infinity, cpu=Infinity, memory=Infinity, io=Infinity, 
network=Infinity]",shape=box]
                rel108 
[label="rel#108:MapSortAggregate\ninput=RelSubset#92,group={},EXPR$0=SUM($0),collation=[]\nrows=1.0,
 cost=IgniteCost [rowCount=Infinity, cpu=Infinity, memory=Infinity, 
io=Infinity, network=Infinity]",shape=box]
                subset104 [label="rel#104:RelSubset#9.IGNITE.random.[]"]
                subset105 [label="rel#105:RelSubset#9.IGNITE.single.[]"]
        }
        root -> subset91;
        subset77 -> rel1;
        subset79 -> rel78; rel78 -> subset77;
        subset80 -> rel2;
        subset82 -> rel81; rel81 -> subset80;
        subset84 -> rel83; rel83 -> subset82;
        subset86 -> rel85; rel85 -> subset84;
        subset88 -> rel87; rel87 -> subset79[label="0"]; rel87 -> 
subset86[label="1"];
        subset90 -> rel89; rel89 -> subset88;
        subset91 -> rel93; rel93 -> subset92;
        subset91 -> rel98; rel98 -> subset96;
        subset91 -> rel101; rel101 -> subset92;
        subset91 -> rel107; rel107 -> subset105;
        subset95 -> rel94; rel94 -> subset88;
        subset96 -> rel97; rel97 -> subset95;
        subset96 -> rel99; rel99 -> subset92;
        subset104 -> rel103; rel103 -> subset102;
        subset105 -> rel106; rel106 -> subset104;
        subset105 -> rel108; rel108 -> subset92;
}
        at 
org.apache.calcite.plan.volcano.RelSubset$CheapestPlanReplacer.visit(RelSubset.java:718)
        at 
org.apache.calcite.plan.volcano.RelSubset.buildCheapestPlan(RelSubset.java:391)
        at 
org.apache.calcite.plan.volcano.VolcanoPlanner.findBestExp(VolcanoPlanner.java:534)
        at 
org.apache.calcite.tools.Programs$RuleSetProgram.run(Programs.java:328)
        at 
org.apache.ignite.internal.sql.engine.prepare.IgnitePlanner.transform(IgnitePlanner.java:386)
        at 
org.apache.ignite.internal.sql.engine.prepare.PlannerHelper.optimize(PlannerHelper.java:140)
        at 
org.apache.ignite.internal.sql.engine.prepare.PrepareServiceImpl.doOptimize(PrepareServiceImpl.java:578)
        at 
org.apache.ignite.internal.sql.engine.prepare.PrepareServiceImpl.lambda$prepareQuery$3(PrepareServiceImpl.java:359)
        at 
java.base/java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1700)
        ... 3 more
{noformat}


> Support WITH RECURSIVE ... AS
> -----------------------------
>
>                 Key: IGNITE-22866
>                 URL: https://issues.apache.org/jira/browse/IGNITE-22866
>             Project: Ignite
>          Issue Type: Improvement
>          Components: general, sql
>    Affects Versions: 3.0.0-beta2
>            Reporter: Igor
>            Priority: Major
>              Labels: ignite-3
>
> *Description:*
> Need to support recursive queries.
> The query
> {code:java}
> WITH RECURSIVE t(n) AS (SELECT 1 UNION ALL SELECT n + 1 FROM t WHERE n < 100) 
> SELECT sum(n) FROM t; {code}
> should return
> {code:java}
> 5050 {code}
> currently returns error
> {noformat}
> org.apache.ignite.sql.SqlException: IGN-CMN-65535 
> TraceId:c2961dbf-64fd-4806-a2d9-20368f8454e5 There are not enough rules to 
> produce a node with desired properties: convention=IGNITE, distr=single, 
> sort=[].
> Missing conversions are LogicalRepeatUnion[convention: NONE -> IGNITE, distr: 
> any -> single], LogicalRepeatUnion[convention: NONE -> IGNITE, distr: any -> 
> random]
> There are 2 empty subsets:
> Empty subset 0: rel#92:RelSubset#6.IGNITE.single.[], the relevant part of the 
> original plan is as follows
> 87:LogicalRepeatUnion(all=[true])
>   78:LogicalTableSpool(subset=[rel#79:RelSubset#1.NONE.any.[0]], 
> readType=[LAZY], writeType=[LAZY], table=[[T]])
>     1:LogicalValues(subset=[rel#77:RelSubset#0.NONE.any.[0]], tuples=[[{ 1 
> }]])
>   85:LogicalTableSpool(subset=[rel#86:RelSubset#5.NONE.any.[]], 
> readType=[LAZY], writeType=[LAZY], table=[[T]])
>     83:LogicalProject(subset=[rel#84:RelSubset#4.NONE.any.[]], EXPR$0=[+($0, 
> 1)])
>       81:LogicalFilter(subset=[rel#82:RelSubset#3.NONE.any.[]], 
> condition=[<($0, 100)])
>         2:LogicalTableScan(subset=[rel#80:RelSubset#2.NONE.any.[]], 
> table=[[T]])
> ... 
> (part of the debug error output was cut out)
> {noformat}



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to