Hello,

I have a Program with a few custom transformation rules that allows me to
transform the following initial tree

LogicalSort(fetch=[5])

  LogicalProject(I=[$0])

    VoltDBTableScan(table=[[R1]], expr#0..5=[{inputs}], proj#0..5=[{exprs}])

that corresponds to the "select i from R1 limit 5;" statement into the
final simplified tree

VoltDBTableScan(table=[[R1]], expr#0..5=[{inputs}], I=[$t0], limit=[5])


where VoltDBTableScan extends Calcite's TableScan with VoltDBConvention
convention and has additional RexProgram and two RexNode data members to
keep filter and limit/offset data.


The same set of rules is capable of optimizing the

LogicalProject(I=[$0])

  LogicalFilter(condition=[>($1, 3)])

    VoltDBTableScan(table=[[R1]], expr#0..5=[{inputs}], proj#0..5=[{exprs}])


tree corresponding to the "select i from R1 where i > 3;" into the same


VoltDBTableScan(table=[[R1]], expr#0..5=[{inputs}], expr#6=[3],
expr#7=[>($t1, $t6)], I=[$t0], $condition=[$t7])

So I was expecting that the "select i from R1 where i > 3 limit 5;" tree

LogicalSort(fetch=[5])

  LogicalProject(I=[$0])

    LogicalFilter(condition=[>($1, 3)])

      VoltDBTableScan(table=[[R1]], expr#0..5=[{inputs}],
proj#0..5=[{exprs}])

would be optimized to be just

VoltDBTableScan(table=[[R1]], expr#0..5=[{inputs}], expr#6=[3],
expr#7=[>($t1, $t6)], I=[$t0], $condition=[$t7], limit=[5])

But instead I am getting the Calcite Planning exception:

Node [rel#15:Subset#3.VOLTDB.[]] could not be implemented; planner state:


Root: rel#15:Subset#3.VOLTDB.[]

Original rel:


Sets:

Set#0, type: RecordType(INTEGER I, SMALLINT SI, TINYINT TI, BIGINT BI,
FLOAT F, VARCHAR(32) V)

rel#8:Subset#0.VOLTDB.[], best=rel#34, importance=0.6561

rel#4:VoltDBTableScan.VOLTDB.[](table=[R1],expr#0..5={inputs},I=$t0,SI=$t1,TI=$t2,BI=$t3,F=$t4,V=$t5),
rowcount=100.0, cumulative cost={100.0 rows, 101.0 cpu, 0.0 io}

rel#34:VoltDBTableScan.VOLTDB.[](table=[R1],expr#0..5={inputs},expr#6=3,expr#7=>($t1,
$t6),I=$t0,SI=$t1,TI=$t2,BI=$t3,F=$t4,V=$t5,$condition=$t7), rowcount=20.0,
cumulative cost={90.0 rows, 101.0 cpu, 0.0 io}

rel#29:Subset#0.NONE.[], best=null, importance=0.7290000000000001

rel#9:LogicalFilter.NONE.[](input=rel#8:Subset#0.VOLTDB.[],condition=>($1,
3)), rowcount=10.0, cumulative cost={inf}

rel#31:LogicalCalc.NONE.[[]](input=rel#8:Subset#0.VOLTDB.[],expr#0..5={inputs},expr#6=3,expr#7=>($t1,
$t6),I=$t0,SI=$t1,TI=$t2,BI=$t3,F=$t4,V=$t5,$condition=$t7), rowcount=10.0,
cumulative cost={inf}

Set#2, type: RecordType(INTEGER I)

rel#12:Subset#2.NONE.[], best=null, importance=0.81

rel#11:LogicalProject.NONE.[](input=rel#29:Subset#0.NONE.[],I=$0),
rowcount=100.0, cumulative cost={inf}

rel#27:LogicalCalc.NONE.[[]](input=rel#29:Subset#0.NONE.[],expr#0..5={inputs},I=$t0),
rowcount=100.0, cumulative cost={inf}

rel#32:LogicalCalc.NONE.[[]](input=rel#8:Subset#0.VOLTDB.[],expr#0..5={inputs},expr#6=3,expr#7=>($t1,
$t6),I=$t0,$condition=$t7), rowcount=10.0, cumulative cost={inf}

rel#26:Subset#2.VOLTDB.[], best=rel#33, importance=0.405

rel#25:VoltDBProject.VOLTDB.[](input=rel#8:Subset#0.VOLTDB.[],I=$0),
rowcount=20.0, cumulative cost={110.0 rows, 121.0 cpu, 0.0 io}

rel#33:VoltDBTableScan.VOLTDB.[](table=[R1],expr#0..5={inputs},expr#6=3,expr#7=>($t1,
$t6),I=$t0,$condition=$t7), rowcount=20.0, cumulative cost={90.0 rows,
101.0 cpu, 0.0 io}

rel#40:VoltDBTableScan.VOLTDB.[](table=[R1],expr#0..5={inputs},I=$t0),
rowcount=100.0, cumulative cost={100.0 rows, 101.0 cpu, 0.0 io}

Set#3, type: RecordType(INTEGER I)

rel#14:Subset#3.NONE.[], best=null, importance=0.9

rel#13:LogicalSort.NONE.[](input=rel#12:Subset#2.NONE.[],fetch=5),
rowcount=5.0, cumulative cost={inf}

rel#20:LogicalProject.NONE.[](input=rel#19:Subset#4.NONE.[],I=$0),
rowcount=5.0, cumulative cost={inf}

rel#23:LogicalCalc.NONE.[[]](input=rel#19:Subset#4.NONE.[],expr#0..5={inputs},I=$t0),
rowcount=5.0, cumulative cost={inf}

rel#15:Subset#3.VOLTDB.[], best=null, importance=1.0

rel#16:AbstractConverter.VOLTDB.[](input=rel#14:Subset#3.NONE.[],convention=VOLTDB,sort=[]),
rowcount=5.0, cumulative cost={inf}

rel#22:VoltDBProject.VOLTDB.[](input=rel#21:Subset#4.VOLTDB.[],I=$0),
rowcount=5.0, cumulative cost={inf}

Set#4, type: RecordType(INTEGER I, SMALLINT SI, TINYINT TI, BIGINT BI,
FLOAT F, VARCHAR(32) V)

rel#19:Subset#4.NONE.[], best=null, importance=0.81

rel#17:LogicalSort.NONE.[](input=rel#29:Subset#0.NONE.[],fetch=5),
rowcount=5.0, cumulative cost={inf}

rel#21:Subset#4.VOLTDB.[], best=null, importance=0.9



Any help is greatly appreciated,

Mike

Reply via email to