You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@calcite.apache.org by Zhangrucong <zh...@huawei.com> on 2016/06/22 03:33:52 UTC

[Calcite] Volcano planner fails to optimize

Hi everyone,

I want to test calcite optimization of volcano planner with null cost factory. To avoid implementing some RelNodes and ConvertRules, I use BindableConvention trait set to transform converted RelNode. The QueryPlanner references to the implementation of SamzaSQL:

https://github.com/milinda/samza-sql/blob/master/samza-sql-planner/src/main/java/org/apache/samza/sql/planner/QueryPlanner.java

I replace the SamzaLogicalConvention.INSTANCE with the BindableConvention.INSTANCE and remove the HepPlanner optimization.

With the simple SQL test("select stream * from orders"), the volcano planner always complains following errors:

org.apache.calcite.plan.RelOptPlanner$CannotPlanException: Node [rel#11:Subset#2.BINDABLE.[]] could not be implemented; planner state:

Root: rel#11:Subset#2.BINDABLE.[]
Original rel:

Sets:
Set#0, type: RecordType(INTEGER orderId, INTEGER productId)
    rel#6:Subset#0.ENUMERABLE.[], best=rel#3, importance=0.7290000000000001
             rel#3:EnumerableTableScan.ENUMERABLE.[](table=[orders]), rowcount=100.0, cumulative cost={100.0 rows, 101.0 cpu, 0.0 io}
    rel#20:Subset#0.BINDABLE.[], best=null, importance=0.36450000000000005
Set#1, type: RecordType(INTEGER orderId, INTEGER productId)
    rel#8:Subset#1.NONE.[], best=null, importance=0.81
             rel#7:LogicalProject.NONE.[](input=rel#6:Subset#0.ENUMERABLE.[],orderId=$0,productId=$1), rowcount=100.0, cumulative cost={inf}
    rel#17:Subset#1.BINDABLE.[], best=null, importance=0.405
             rel#16:InterpretableConverter.BINDABLE.[](input=rel#8:Subset#1.NONE.[]), rowcount=100.0, cumulative cost={inf}
             rel#21:BindableProject.BINDABLE.[](input=rel#20:Subset#0.BINDABLE.[],orderId=$0,productId=$1), rowcount=100.0, cumulative cost={inf}
Set#2, type: RecordType(INTEGER orderId, INTEGER productId)
    rel#10:Subset#2.NONE.[], best=null, importance=0.9
             rel#9:LogicalDelta.NONE.[](input=rel#8:Subset#1.NONE.[]), rowcount=100.0, cumulative cost={inf}
    rel#11:Subset#2.BINDABLE.[], best=null, importance=1.0
             rel#12:AbstractConverter.BINDABLE.[](input=rel#10:Subset#2.NONE.[],convention=BINDABLE,sort=[]), rowcount=100.0, cumulative cost={inf}
             rel#13:InterpretableConverter.BINDABLE.[](input=rel#10:Subset#2.NONE.[]), rowcount=100.0, cumulative cost={inf}

    at org.apache.calcite.plan.volcano.RelSubset$CheapestPlanReplacer.visit(RelSubset.java:443)
    at org.apache.calcite.plan.volcano.RelSubset.buildCheapestPlan(RelSubset.java:293)
    at org.apache.calcite.plan.volcano.VolcanoPlanner.findBestExp(VolcanoPlanner.java:841)
    at org.apache.calcite.tools.Programs$RuleSetProgram.run(Programs.java:334)
    at org.apache.calcite.prepare.PlannerImpl.transform(PlannerImpl.java:290)

I have no idea what to do with the runtime exceptions. Anything did I forget ? Or Did I misuse the BindableConvention trait set ?

Thanks.



Re: [Calcite] Volcano planner fails to optimize

Posted by Milinda Pathirage <mp...@umail.iu.edu>.
Hi Ravikumar,

Please go through your planner state and figure out which rels are still in
NONE convention. Once you fix your converter rules the error will go away.

Thanks
Milinda

On Wed, Jun 22, 2016 at 11:33 AM, Ravikumar CS <ra...@gmail.com>
wrote:

> I ran into a similar issue with VolcanoPlanner. Not sure how to get past
> this.
>
>
> Exception in thread "main"
> org.apache.calcite.plan.RelOptPlanner$CannotPlanException: Node
> [rel#17:Subset#3.NONE.[]] could not be implemented; planner state:
>
> Root: rel#17:Subset#3.NONE.[]
> Original rel:
> LogicalAggregate(subset=[rel#17:Subset#3.NONE.[]], group=[{0}],
> EXPR$1=[SUM($1)]): rowcount = 5.0, cumulative cost = {5.687500238418579
> rows, 0.0 cpu, 0.0 io}, id = 16
>   LogicalFilter(subset=[rel#15:Subset#2.NONE.[]], condition=[>($0, 1)]):
> rowcount = 50.0, cumulative cost = {50.0 rows, 100.0 cpu, 0.0 io}, id = 14
>     LogicalProject(subset=[rel#13:Subset#1.NONE.[]], id=[$0], units=[$2]):
> rowcount = 100.0, cumulative cost = {100.0 rows, 200.0 cpu, 0.0 io}, id =
> 12
>       LogicalTableScan(subset=[rel#11:Subset#0.NONE.[]], table=[[SALES,
> Orders1]]): rowcount = 100.0, cumulative cost = {100.0 rows, 101.0 cpu, 0.0
> io}, id = 4
>
> Sets:
> Set#0, type: RecordType(INTEGER id, VARCHAR(10) product, INTEGER units)
> rel#11:Subset#0.NONE.[], best=null, importance=0.7290000000000001
> rel#4:LogicalTableScan.NONE.[](table=[SALES, Orders1]), rowcount=100.0,
> cumulative cost={inf}
> rel#53:Subset#0.BINDABLE.[], best=rel#52, importance=0.5904900000000001
> rel#52:BindableTableScan.BINDABLE.[](table=[SALES, Orders1]),
> rowcount=100.0, cumulative cost={1.0 rows, 1.01 cpu, 0.0 io}
> rel#55:Subset#0.ENUMERABLE.[], best=rel#69, importance=0.6561
> rel#54:EnumerableTableScan.ENUMERABLE.[](table=[SALES, Orders1]),
> rowcount=100.0, cumulative cost={100.0 rows, 101.0 cpu, 0.0 io}
>
> rel#69:EnumerableInterpreter.ENUMERABLE.[](input=rel#53:Subset#0.BINDABLE.[]),
> rowcount=100.0, cumulative cost={51.0 rows, 51.01 cpu, 0.0 io}
> Set#1, type: RecordType(INTEGER id, INTEGER units)
> rel#13:Subset#1.NONE.[], best=null, importance=0.81
>
> rel#12:LogicalProject.NONE.[](input=rel#11:Subset#0.NONE.[],id=$0,units=$2),
> rowcount=100.0, cumulative cost={inf}
> rel#60:Subset#1.ENUMERABLE.[], best=rel#59, importance=0.7290000000000001
>
> rel#59:EnumerableProject.ENUMERABLE.[](input=rel#55:Subset#0.ENUMERABLE.[],id=$0,units=$2),
> rowcount=100.0, cumulative cost={151.0 rows, 251.01 cpu, 0.0 io}
> Set#2, type: RecordType(INTEGER id, INTEGER units)
> rel#15:Subset#2.NONE.[], best=null, importance=0.9
> rel#14:LogicalFilter.NONE.[](input=rel#13:Subset#1.NONE.[],condition=>($0,
> 1)), rowcount=50.0, cumulative cost={inf}
>
> rel#41:LogicalProject.NONE.[](input=rel#40:Subset#4.NONE.[],id=$0,units=$2),
> rowcount=50.0, cumulative cost={inf}
> rel#34:Subset#2.ENUMERABLE.[], best=rel#56, importance=0.81
>
> rel#56:EnumerableProject.ENUMERABLE.[](input=rel#43:Subset#4.ENUMERABLE.[],id=$0,units=$2),
> rowcount=50.0, cumulative cost={151.0 rows, 251.01 cpu, 0.0 io}
>
> rel#61:EnumerableFilter.ENUMERABLE.[](input=rel#60:Subset#1.ENUMERABLE.[],condition=>($0,
> 1)), rowcount=50.0, cumulative cost={201.0 rows, 351.01 cpu, 0.0 io}
> Set#3, type: RecordType(INTEGER id, INTEGER EXPR$1)
> rel#17:Subset#3.NONE.[], best=null, importance=1.0
>
> rel#16:LogicalAggregate.NONE.[](input=rel#15:Subset#2.NONE.[],group={0},EXPR$1=SUM($1)),
> rowcount=5.0, cumulative cost={inf}
>
> rel#32:AbstractConverter.NONE.[](input=rel#31:Subset#3.ENUMERABLE.[],convention=NONE,sort=[]),
> rowcount=5.0, cumulative cost={inf}
>
> rel#36:LogicalAggregate.NONE.[](input=rel#15:Subset#2.NONE.[],group={0},EXPR$1=$SUM0($1)),
> rowcount=5.0, cumulative cost={inf}
>
> rel#42:LogicalAggregate.NONE.[](input=rel#40:Subset#4.NONE.[],group={0},EXPR$1=$SUM0($2)),
> rowcount=5.0, cumulative cost={inf}
>
> rel#45:LogicalAggregate.NONE.[](input=rel#40:Subset#4.NONE.[],group={0},EXPR$1=SUM($2)),
> rowcount=5.0, cumulative cost={inf}
> rel#31:Subset#3.ENUMERABLE.[], best=rel#44, importance=0.9
>
> rel#33:AbstractConverter.ENUMERABLE.[](input=rel#17:Subset#3.NONE.[],convention=ENUMERABLE,sort=[]),
> rowcount=5.0, cumulative cost={inf}
>
> rel#35:EnumerableAggregate.ENUMERABLE.[](input=rel#34:Subset#2.ENUMERABLE.[],group={0},EXPR$1=SUM($1)),
> rowcount=5.0, cumulative cost={156.68750023841858 rows, 251.01 cpu, 0.0 io}
>
> rel#37:EnumerableAggregate.ENUMERABLE.[](input=rel#34:Subset#2.ENUMERABLE.[],group={0},EXPR$1=$SUM0($1)),
> rowcount=5.0, cumulative cost={156.625 rows, 251.01 cpu, 0.0 io}
>
> rel#44:EnumerableAggregate.ENUMERABLE.[](input=rel#43:Subset#4.ENUMERABLE.[],group={0},EXPR$1=$SUM0($2)),
> rowcount=5.0, cumulative cost={106.625 rows, 151.01 cpu, 0.0 io}
>
> rel#46:EnumerableAggregate.ENUMERABLE.[](input=rel#43:Subset#4.ENUMERABLE.[],group={0},EXPR$1=SUM($2)),
> rowcount=5.0, cumulative cost={106.68750023841858 rows, 151.01 cpu, 0.0 io}
> Set#4, type: RecordType(INTEGER id, VARCHAR(10) product, INTEGER units)
> rel#40:Subset#4.NONE.[], best=null, importance=0.81
> rel#38:LogicalFilter.NONE.[](input=rel#11:Subset#0.NONE.[],condition=>($0,
> 1)), rowcount=50.0, cumulative cost={inf}
> rel#43:Subset#4.ENUMERABLE.[], best=rel#62, importance=0.7290000000000001
>
> rel#62:EnumerableFilter.ENUMERABLE.[](input=rel#55:Subset#0.ENUMERABLE.[],condition=>($0,
> 1)), rowcount=50.0, cumulative cost={101.0 rows, 151.01 cpu, 0.0 io}
> at
>
> org.apache.calcite.plan.volcano.RelSubset$CheapestPlanReplacer.visit(RelSubset.java:443)
> at
>
> org.apache.calcite.plan.volcano.RelSubset.buildCheapestPlan(RelSubset.java:293)
> at
>
> org.apache.calcite.plan.volcano.VolcanoPlanner.findBestExp(VolcanoPlanner.java:841)
> at
>
> com.calcite.prototype.queryengine.BasicQueryPlanner.main(BasicQueryPlanner.java:133)
>
>
> On Tue, Jun 21, 2016 at 8:33 PM, Zhangrucong <zh...@huawei.com>
> wrote:
>
> > Hi everyone,
> >
> > I want to test calcite optimization of volcano planner with null cost
> > factory. To avoid implementing some RelNodes and ConvertRules, I use
> > BindableConvention trait set to transform converted RelNode. The
> > QueryPlanner references to the implementation of SamzaSQL:
> >
> >
> >
> https://github.com/milinda/samza-sql/blob/master/samza-sql-planner/src/main/java/org/apache/samza/sql/planner/QueryPlanner.java
> >
> > I replace the SamzaLogicalConvention.INSTANCE with the
> > BindableConvention.INSTANCE and remove the HepPlanner optimization.
> >
> > With the simple SQL test("select stream * from orders"), the volcano
> > planner always complains following errors:
> >
> > org.apache.calcite.plan.RelOptPlanner$CannotPlanException: Node
> > [rel#11:Subset#2.BINDABLE.[]] could not be implemented; planner state:
> >
> > Root: rel#11:Subset#2.BINDABLE.[]
> > Original rel:
> >
> > Sets:
> > Set#0, type: RecordType(INTEGER orderId, INTEGER productId)
> >     rel#6:Subset#0.ENUMERABLE.[], best=rel#3,
> importance=0.7290000000000001
> >              rel#3:EnumerableTableScan.ENUMERABLE.[](table=[orders]),
> > rowcount=100.0, cumulative cost={100.0 rows, 101.0 cpu, 0.0 io}
> >     rel#20:Subset#0.BINDABLE.[], best=null,
> importance=0.36450000000000005
> > Set#1, type: RecordType(INTEGER orderId, INTEGER productId)
> >     rel#8:Subset#1.NONE.[], best=null, importance=0.81
> >
> >
> rel#7:LogicalProject.NONE.[](input=rel#6:Subset#0.ENUMERABLE.[],orderId=$0,productId=$1),
> > rowcount=100.0, cumulative cost={inf}
> >     rel#17:Subset#1.BINDABLE.[], best=null, importance=0.405
> >
> >  rel#16:InterpretableConverter.BINDABLE.[](input=rel#8:Subset#1.NONE.[]),
> > rowcount=100.0, cumulative cost={inf}
> >
> >
> rel#21:BindableProject.BINDABLE.[](input=rel#20:Subset#0.BINDABLE.[],orderId=$0,productId=$1),
> > rowcount=100.0, cumulative cost={inf}
> > Set#2, type: RecordType(INTEGER orderId, INTEGER productId)
> >     rel#10:Subset#2.NONE.[], best=null, importance=0.9
> >              rel#9:LogicalDelta.NONE.[](input=rel#8:Subset#1.NONE.[]),
> > rowcount=100.0, cumulative cost={inf}
> >     rel#11:Subset#2.BINDABLE.[], best=null, importance=1.0
> >
> >
> rel#12:AbstractConverter.BINDABLE.[](input=rel#10:Subset#2.NONE.[],convention=BINDABLE,sort=[]),
> > rowcount=100.0, cumulative cost={inf}
> >
> >
> rel#13:InterpretableConverter.BINDABLE.[](input=rel#10:Subset#2.NONE.[]),
> > rowcount=100.0, cumulative cost={inf}
> >
> >     at
> >
> org.apache.calcite.plan.volcano.RelSubset$CheapestPlanReplacer.visit(RelSubset.java:443)
> >     at
> >
> org.apache.calcite.plan.volcano.RelSubset.buildCheapestPlan(RelSubset.java:293)
> >     at
> >
> org.apache.calcite.plan.volcano.VolcanoPlanner.findBestExp(VolcanoPlanner.java:841)
> >     at
> > org.apache.calcite.tools.Programs$RuleSetProgram.run(Programs.java:334)
> >     at
> > org.apache.calcite.prepare.PlannerImpl.transform(PlannerImpl.java:290)
> >
> > I have no idea what to do with the runtime exceptions. Anything did I
> > forget ? Or Did I misuse the BindableConvention trait set ?
> >
> > Thanks.
> >
> >
> >
>



-- 
Milinda Pathirage

PhD Student | Research Assistant
School of Informatics and Computing | Data to Insight Center
Indiana University

twitter: milindalakmal
skype: milinda.pathirage
blog: http://milinda.pathirage.org

Re: [Calcite] Volcano planner fails to optimize

Posted by Ravikumar CS <ra...@gmail.com>.
I ran into a similar issue with VolcanoPlanner. Not sure how to get past
this.


Exception in thread "main"
org.apache.calcite.plan.RelOptPlanner$CannotPlanException: Node
[rel#17:Subset#3.NONE.[]] could not be implemented; planner state:

Root: rel#17:Subset#3.NONE.[]
Original rel:
LogicalAggregate(subset=[rel#17:Subset#3.NONE.[]], group=[{0}],
EXPR$1=[SUM($1)]): rowcount = 5.0, cumulative cost = {5.687500238418579
rows, 0.0 cpu, 0.0 io}, id = 16
  LogicalFilter(subset=[rel#15:Subset#2.NONE.[]], condition=[>($0, 1)]):
rowcount = 50.0, cumulative cost = {50.0 rows, 100.0 cpu, 0.0 io}, id = 14
    LogicalProject(subset=[rel#13:Subset#1.NONE.[]], id=[$0], units=[$2]):
rowcount = 100.0, cumulative cost = {100.0 rows, 200.0 cpu, 0.0 io}, id = 12
      LogicalTableScan(subset=[rel#11:Subset#0.NONE.[]], table=[[SALES,
Orders1]]): rowcount = 100.0, cumulative cost = {100.0 rows, 101.0 cpu, 0.0
io}, id = 4

Sets:
Set#0, type: RecordType(INTEGER id, VARCHAR(10) product, INTEGER units)
rel#11:Subset#0.NONE.[], best=null, importance=0.7290000000000001
rel#4:LogicalTableScan.NONE.[](table=[SALES, Orders1]), rowcount=100.0,
cumulative cost={inf}
rel#53:Subset#0.BINDABLE.[], best=rel#52, importance=0.5904900000000001
rel#52:BindableTableScan.BINDABLE.[](table=[SALES, Orders1]),
rowcount=100.0, cumulative cost={1.0 rows, 1.01 cpu, 0.0 io}
rel#55:Subset#0.ENUMERABLE.[], best=rel#69, importance=0.6561
rel#54:EnumerableTableScan.ENUMERABLE.[](table=[SALES, Orders1]),
rowcount=100.0, cumulative cost={100.0 rows, 101.0 cpu, 0.0 io}
rel#69:EnumerableInterpreter.ENUMERABLE.[](input=rel#53:Subset#0.BINDABLE.[]),
rowcount=100.0, cumulative cost={51.0 rows, 51.01 cpu, 0.0 io}
Set#1, type: RecordType(INTEGER id, INTEGER units)
rel#13:Subset#1.NONE.[], best=null, importance=0.81
rel#12:LogicalProject.NONE.[](input=rel#11:Subset#0.NONE.[],id=$0,units=$2),
rowcount=100.0, cumulative cost={inf}
rel#60:Subset#1.ENUMERABLE.[], best=rel#59, importance=0.7290000000000001
rel#59:EnumerableProject.ENUMERABLE.[](input=rel#55:Subset#0.ENUMERABLE.[],id=$0,units=$2),
rowcount=100.0, cumulative cost={151.0 rows, 251.01 cpu, 0.0 io}
Set#2, type: RecordType(INTEGER id, INTEGER units)
rel#15:Subset#2.NONE.[], best=null, importance=0.9
rel#14:LogicalFilter.NONE.[](input=rel#13:Subset#1.NONE.[],condition=>($0,
1)), rowcount=50.0, cumulative cost={inf}
rel#41:LogicalProject.NONE.[](input=rel#40:Subset#4.NONE.[],id=$0,units=$2),
rowcount=50.0, cumulative cost={inf}
rel#34:Subset#2.ENUMERABLE.[], best=rel#56, importance=0.81
rel#56:EnumerableProject.ENUMERABLE.[](input=rel#43:Subset#4.ENUMERABLE.[],id=$0,units=$2),
rowcount=50.0, cumulative cost={151.0 rows, 251.01 cpu, 0.0 io}
rel#61:EnumerableFilter.ENUMERABLE.[](input=rel#60:Subset#1.ENUMERABLE.[],condition=>($0,
1)), rowcount=50.0, cumulative cost={201.0 rows, 351.01 cpu, 0.0 io}
Set#3, type: RecordType(INTEGER id, INTEGER EXPR$1)
rel#17:Subset#3.NONE.[], best=null, importance=1.0
rel#16:LogicalAggregate.NONE.[](input=rel#15:Subset#2.NONE.[],group={0},EXPR$1=SUM($1)),
rowcount=5.0, cumulative cost={inf}
rel#32:AbstractConverter.NONE.[](input=rel#31:Subset#3.ENUMERABLE.[],convention=NONE,sort=[]),
rowcount=5.0, cumulative cost={inf}
rel#36:LogicalAggregate.NONE.[](input=rel#15:Subset#2.NONE.[],group={0},EXPR$1=$SUM0($1)),
rowcount=5.0, cumulative cost={inf}
rel#42:LogicalAggregate.NONE.[](input=rel#40:Subset#4.NONE.[],group={0},EXPR$1=$SUM0($2)),
rowcount=5.0, cumulative cost={inf}
rel#45:LogicalAggregate.NONE.[](input=rel#40:Subset#4.NONE.[],group={0},EXPR$1=SUM($2)),
rowcount=5.0, cumulative cost={inf}
rel#31:Subset#3.ENUMERABLE.[], best=rel#44, importance=0.9
rel#33:AbstractConverter.ENUMERABLE.[](input=rel#17:Subset#3.NONE.[],convention=ENUMERABLE,sort=[]),
rowcount=5.0, cumulative cost={inf}
rel#35:EnumerableAggregate.ENUMERABLE.[](input=rel#34:Subset#2.ENUMERABLE.[],group={0},EXPR$1=SUM($1)),
rowcount=5.0, cumulative cost={156.68750023841858 rows, 251.01 cpu, 0.0 io}
rel#37:EnumerableAggregate.ENUMERABLE.[](input=rel#34:Subset#2.ENUMERABLE.[],group={0},EXPR$1=$SUM0($1)),
rowcount=5.0, cumulative cost={156.625 rows, 251.01 cpu, 0.0 io}
rel#44:EnumerableAggregate.ENUMERABLE.[](input=rel#43:Subset#4.ENUMERABLE.[],group={0},EXPR$1=$SUM0($2)),
rowcount=5.0, cumulative cost={106.625 rows, 151.01 cpu, 0.0 io}
rel#46:EnumerableAggregate.ENUMERABLE.[](input=rel#43:Subset#4.ENUMERABLE.[],group={0},EXPR$1=SUM($2)),
rowcount=5.0, cumulative cost={106.68750023841858 rows, 151.01 cpu, 0.0 io}
Set#4, type: RecordType(INTEGER id, VARCHAR(10) product, INTEGER units)
rel#40:Subset#4.NONE.[], best=null, importance=0.81
rel#38:LogicalFilter.NONE.[](input=rel#11:Subset#0.NONE.[],condition=>($0,
1)), rowcount=50.0, cumulative cost={inf}
rel#43:Subset#4.ENUMERABLE.[], best=rel#62, importance=0.7290000000000001
rel#62:EnumerableFilter.ENUMERABLE.[](input=rel#55:Subset#0.ENUMERABLE.[],condition=>($0,
1)), rowcount=50.0, cumulative cost={101.0 rows, 151.01 cpu, 0.0 io}
at
org.apache.calcite.plan.volcano.RelSubset$CheapestPlanReplacer.visit(RelSubset.java:443)
at
org.apache.calcite.plan.volcano.RelSubset.buildCheapestPlan(RelSubset.java:293)
at
org.apache.calcite.plan.volcano.VolcanoPlanner.findBestExp(VolcanoPlanner.java:841)
at
com.calcite.prototype.queryengine.BasicQueryPlanner.main(BasicQueryPlanner.java:133)


On Tue, Jun 21, 2016 at 8:33 PM, Zhangrucong <zh...@huawei.com> wrote:

> Hi everyone,
>
> I want to test calcite optimization of volcano planner with null cost
> factory. To avoid implementing some RelNodes and ConvertRules, I use
> BindableConvention trait set to transform converted RelNode. The
> QueryPlanner references to the implementation of SamzaSQL:
>
>
> https://github.com/milinda/samza-sql/blob/master/samza-sql-planner/src/main/java/org/apache/samza/sql/planner/QueryPlanner.java
>
> I replace the SamzaLogicalConvention.INSTANCE with the
> BindableConvention.INSTANCE and remove the HepPlanner optimization.
>
> With the simple SQL test("select stream * from orders"), the volcano
> planner always complains following errors:
>
> org.apache.calcite.plan.RelOptPlanner$CannotPlanException: Node
> [rel#11:Subset#2.BINDABLE.[]] could not be implemented; planner state:
>
> Root: rel#11:Subset#2.BINDABLE.[]
> Original rel:
>
> Sets:
> Set#0, type: RecordType(INTEGER orderId, INTEGER productId)
>     rel#6:Subset#0.ENUMERABLE.[], best=rel#3, importance=0.7290000000000001
>              rel#3:EnumerableTableScan.ENUMERABLE.[](table=[orders]),
> rowcount=100.0, cumulative cost={100.0 rows, 101.0 cpu, 0.0 io}
>     rel#20:Subset#0.BINDABLE.[], best=null, importance=0.36450000000000005
> Set#1, type: RecordType(INTEGER orderId, INTEGER productId)
>     rel#8:Subset#1.NONE.[], best=null, importance=0.81
>
>  rel#7:LogicalProject.NONE.[](input=rel#6:Subset#0.ENUMERABLE.[],orderId=$0,productId=$1),
> rowcount=100.0, cumulative cost={inf}
>     rel#17:Subset#1.BINDABLE.[], best=null, importance=0.405
>
>  rel#16:InterpretableConverter.BINDABLE.[](input=rel#8:Subset#1.NONE.[]),
> rowcount=100.0, cumulative cost={inf}
>
>  rel#21:BindableProject.BINDABLE.[](input=rel#20:Subset#0.BINDABLE.[],orderId=$0,productId=$1),
> rowcount=100.0, cumulative cost={inf}
> Set#2, type: RecordType(INTEGER orderId, INTEGER productId)
>     rel#10:Subset#2.NONE.[], best=null, importance=0.9
>              rel#9:LogicalDelta.NONE.[](input=rel#8:Subset#1.NONE.[]),
> rowcount=100.0, cumulative cost={inf}
>     rel#11:Subset#2.BINDABLE.[], best=null, importance=1.0
>
>  rel#12:AbstractConverter.BINDABLE.[](input=rel#10:Subset#2.NONE.[],convention=BINDABLE,sort=[]),
> rowcount=100.0, cumulative cost={inf}
>
>  rel#13:InterpretableConverter.BINDABLE.[](input=rel#10:Subset#2.NONE.[]),
> rowcount=100.0, cumulative cost={inf}
>
>     at
> org.apache.calcite.plan.volcano.RelSubset$CheapestPlanReplacer.visit(RelSubset.java:443)
>     at
> org.apache.calcite.plan.volcano.RelSubset.buildCheapestPlan(RelSubset.java:293)
>     at
> org.apache.calcite.plan.volcano.VolcanoPlanner.findBestExp(VolcanoPlanner.java:841)
>     at
> org.apache.calcite.tools.Programs$RuleSetProgram.run(Programs.java:334)
>     at
> org.apache.calcite.prepare.PlannerImpl.transform(PlannerImpl.java:290)
>
> I have no idea what to do with the runtime exceptions. Anything did I
> forget ? Or Did I misuse the BindableConvention trait set ?
>
> Thanks.
>
>
>

Re: 答复: [Calcite] Volcano planner fails to optimize

Posted by Milinda Pathirage <mp...@umail.iu.edu>.
Sorry for the mistake on my side. I totally forgot some rules may check for
specific implementations of Table, etc. As I understand this has something
to do with the Calcite interpreter implementation (Please have a look at
org.apache.calcite.interpreter package). Interpreter calls 'scan' method of
the table to read the rows. So this basically depends on how your query
execution engine is implemented.

Thanks
Milinda

On Wed, Jun 22, 2016 at 11:13 PM, Zhangrucong <zh...@huawei.com>
wrote:

> Hi Milinda,
>
> Thanks for your help.
>
> In Bindables.RULES, there is a BINDABLE_PROJECT_RULE for converting
> LogicalProject RelNode. So, I think it is not the reason of convention
> failure.
> When I make the test table class implement TranslatableTable and
> FilterableTable interface, volcano planner works well. In addition to
> FilterableTable, ProjectableFilterable and Scannable interfaces also fix
> that exception.
>
> But I have a little knowledge of the reason that the bindable rules
> require a translatable and filterable(or ProjectableFilterable, scannable)
> table.
> Could you give me an explanation?
>
> -----邮件原件-----
> 发件人: Milinda Pathirage [mailto:mpathira@umail.iu.edu]
> 发送时间: 2016年6月23日 0:14
> 收件人: dev@calcite.apache.org
> 主题: Re: [Calcite] Volcano planner fails to optimize
>
> Hi,
>
> I think this is caused by missing LogicalProject converter rule. You can
> figure which rules are missing by going through the planner state. The
> error message says 'Node [rel#11:Subset#2.BINDABLE.[]] could not be
> implemented'.  That is because rel#11:Subset#2 has children whose inputs
> are still in NONE convention. For examples, rel#12:AbstractConverter's
> input 'rel#10:Subset#2' is still in NONE convention. This is because
> rel#9:LogicalDelta is missing its convention (or in NONE). Then if we look
> at the input to this delta, you can see that input's (rel#8:Subset#1)
> convention is also NONE. rel#8:Subset#1's convention is NONE because
> rel#7:LogicalProject has NONE convention.
>
> Thanks
> Milinda
>
> On Tue, Jun 21, 2016 at 11:33 PM, Zhangrucong <zh...@huawei.com>
> wrote:
>
> > Hi everyone,
> >
> > I want to test calcite optimization of volcano planner with null cost
> > factory. To avoid implementing some RelNodes and ConvertRules, I use
> > BindableConvention trait set to transform converted RelNode. The
> > QueryPlanner references to the implementation of SamzaSQL:
> >
> >
> > https://github.com/milinda/samza-sql/blob/master/samza-sql-planner/src
> > /main/java/org/apache/samza/sql/planner/QueryPlanner.java
> >
> > I replace the SamzaLogicalConvention.INSTANCE with the
> > BindableConvention.INSTANCE and remove the HepPlanner optimization.
> >
> > With the simple SQL test("select stream * from orders"), the volcano
> > planner always complains following errors:
> >
> > org.apache.calcite.plan.RelOptPlanner$CannotPlanException: Node
> > [rel#11:Subset#2.BINDABLE.[]] could not be implemented; planner state:
> >
> > Root: rel#11:Subset#2.BINDABLE.[]
> > Original rel:
> >
> > Sets:
> > Set#0, type: RecordType(INTEGER orderId, INTEGER productId)
> >     rel#6:Subset#0.ENUMERABLE.[], best=rel#3,
> importance=0.7290000000000001
> >              rel#3:EnumerableTableScan.ENUMERABLE.[](table=[orders]),
> > rowcount=100.0, cumulative cost={100.0 rows, 101.0 cpu, 0.0 io}
> >     rel#20:Subset#0.BINDABLE.[], best=null,
> > importance=0.36450000000000005 Set#1, type: RecordType(INTEGER orderId,
> INTEGER productId)
> >     rel#8:Subset#1.NONE.[], best=null, importance=0.81
> >
> >
> > rel#7:LogicalProject.NONE.[](input=rel#6:Subset#0.ENUMERABLE.[],orderI
> > d=$0,productId=$1),
> > rowcount=100.0, cumulative cost={inf}
> >     rel#17:Subset#1.BINDABLE.[], best=null, importance=0.405
> >
> >
> > rel#16:InterpretableConverter.BINDABLE.[](input=rel#8:Subset#1.NONE.[]
> > ),
> > rowcount=100.0, cumulative cost={inf}
> >
> >
> > rel#21:BindableProject.BINDABLE.[](input=rel#20:Subset#0.BINDABLE.[],o
> > rderId=$0,productId=$1),
> > rowcount=100.0, cumulative cost={inf}
> > Set#2, type: RecordType(INTEGER orderId, INTEGER productId)
> >     rel#10:Subset#2.NONE.[], best=null, importance=0.9
> >              rel#9:LogicalDelta.NONE.[](input=rel#8:Subset#1.NONE.[]),
> > rowcount=100.0, cumulative cost={inf}
> >     rel#11:Subset#2.BINDABLE.[], best=null, importance=1.0
> >
> >
> > rel#12:AbstractConverter.BINDABLE.[](input=rel#10:Subset#2.NONE.[],con
> > vention=BINDABLE,sort=[]),
> > rowcount=100.0, cumulative cost={inf}
> >
> >
> > rel#13:InterpretableConverter.BINDABLE.[](input=rel#10:Subset#2.NONE.[
> > ]),
> > rowcount=100.0, cumulative cost={inf}
> >
> >     at
> >
> org.apache.calcite.plan.volcano.RelSubset$CheapestPlanReplacer.visit(RelSubset.java:443)
> >     at
> >
> org.apache.calcite.plan.volcano.RelSubset.buildCheapestPlan(RelSubset.java:293)
> >     at
> >
> org.apache.calcite.plan.volcano.VolcanoPlanner.findBestExp(VolcanoPlanner.java:841)
> >     at
> > org.apache.calcite.tools.Programs$RuleSetProgram.run(Programs.java:334)
> >     at
> > org.apache.calcite.prepare.PlannerImpl.transform(PlannerImpl.java:290)
> >
> > I have no idea what to do with the runtime exceptions. Anything did I
> > forget ? Or Did I misuse the BindableConvention trait set ?
> >
> > Thanks.
> >
> >
> >
>
>
> --
> Milinda Pathirage
>
> PhD Student | Research Assistant
> School of Informatics and Computing | Data to Insight Center Indiana
> University
>
> twitter: milindalakmal
> skype: milinda.pathirage
> blog: http://milinda.pathirage.org
>



-- 
Milinda Pathirage

PhD Student | Research Assistant
School of Informatics and Computing | Data to Insight Center
Indiana University

twitter: milindalakmal
skype: milinda.pathirage
blog: http://milinda.pathirage.org

Re: 答复: [Calcite] Volcano planner fails to optimize

Posted by Ravikumar CS <ra...@gmail.com>.
The VolcanoPlanner started to work after I changed the table to Scannable and
by explicitly changing to EnumerableConvention. Now, VolcanoPlanner object does
not do anything and I get the initial query plan back unmodified but
in EnumerableConvention.

This had worked just fine with HepPlanner.


*1. Initial LogicalPlan:*

LogicalProject(id=[$0], sum_units=[$1], sum_id=[+($1, $0)])

  LogicalAggregate(group=[{0}], sum_units=[SUM($1)])

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

      LogicalUnion(all=[true])

        LogicalProject(id=[$0], units=[$2])

          LogicalTableScan(table=[[SALES, Orders1]])

        LogicalProject(id=[$0], units=[$2])


*2. After changing the traitset:*

RelOptPlanner planner = loginalPlan
.getCluster().getPlanner().chooseDelegate();

RelTraitSet desiredTraits = loginalPlan
.getTraitSet().replace(EnumerableConvention.INSTANCE);

loginalPlan = planner.changeTraits(loginalPlan, desiredTraits);

AbstractConverter(subset=[rel#62:Subset#7.ENUMERABLE.[]],
convention=[ENUMERABLE], sort=[[]])
  LogicalProject(subset=[rel#35:Subset#7.NONE.[]], id=[$0], sum_units=[$1],
sum_id=[+($1, $0)])
    LogicalAggregate(subset=[rel#33:Subset#6.NONE.[]], group=[{0}],
sum_units=[SUM($1)])
      LogicalFilter(subset=[rel#31:Subset#5.NONE.[]], condition=[>($0, 1)])
        LogicalUnion(subset=[rel#29:Subset#4.NONE.[]], all=[true])
          LogicalProject(subset=[rel#24:Subset#1.NONE.[]], id=[$0],
units=[$2])
            LogicalTableScan(subset=[rel#22:Subset#0.NONE.[]],
table=[[SALES, Orders1]])
          LogicalProject(subset=[rel#27:Subset#3.NONE.[]], id=[$0],
units=[$2])
            LogicalTableScan(subset=[rel#25:Subset#2.NONE.[]],
table=[[SALES, Orders2]])

*3. Final running of Volcano planner:*

    planner.addRule(FilterSetOpTransposeRule.INSTANCE);

    planner.addRule(AggregateReduceFunctionsRule.INSTANCE);

    planner.addRule(AggregateUnionTransposeRule.INSTANCE);

    planner.setRoot(loginalPlan);

    System.out.println(RelOptUtil.toString(planner.findBestExp()));


EnumerableProject(id=[$0], sum_units=[$1], sum_id=[+($1, $0)])
  EnumerableAggregate(group=[{0}], sum_units=[$SUM0($1)])
    EnumerableFilter(condition=[>($0, 1)])
      EnumerableUnion(all=[true])
        EnumerableProject(id=[$0], units=[$2])
          EnumerableInterpreter
            BindableTableScan(table=[[SALES, Orders1]])
        EnumerableProject(id=[$0], units=[$2])
          EnumerableInterpreter
            BindableTableScan(table=[[SALES, Orders2]])




On Wed, Jun 22, 2016 at 8:13 PM, Zhangrucong <zh...@huawei.com> wrote:

> Hi Milinda,
>
> Thanks for your help.
>
> In Bindables.RULES, there is a BINDABLE_PROJECT_RULE for converting
> LogicalProject RelNode. So, I think it is not the reason of convention
> failure.
> When I make the test table class implement TranslatableTable and
> FilterableTable interface, volcano planner works well. In addition to
> FilterableTable, ProjectableFilterable and Scannable interfaces also fix
> that exception.
>
> But I have a little knowledge of the reason that the bindable rules
> require a translatable and filterable(or ProjectableFilterable, scannable)
> table.
> Could you give me an explanation?
>
> -----邮件原件-----
> 发件人: Milinda Pathirage [mailto:mpathira@umail.iu.edu]
> 发送时间: 2016年6月23日 0:14
> 收件人: dev@calcite.apache.org
> 主题: Re: [Calcite] Volcano planner fails to optimize
>
> Hi,
>
> I think this is caused by missing LogicalProject converter rule. You can
> figure which rules are missing by going through the planner state. The
> error message says 'Node [rel#11:Subset#2.BINDABLE.[]] could not be
> implemented'.  That is because rel#11:Subset#2 has children whose inputs
> are still in NONE convention. For examples, rel#12:AbstractConverter's
> input 'rel#10:Subset#2' is still in NONE convention. This is because
> rel#9:LogicalDelta is missing its convention (or in NONE). Then if we look
> at the input to this delta, you can see that input's (rel#8:Subset#1)
> convention is also NONE. rel#8:Subset#1's convention is NONE because
> rel#7:LogicalProject has NONE convention.
>
> Thanks
> Milinda
>
> On Tue, Jun 21, 2016 at 11:33 PM, Zhangrucong <zh...@huawei.com>
> wrote:
>
> > Hi everyone,
> >
> > I want to test calcite optimization of volcano planner with null cost
> > factory. To avoid implementing some RelNodes and ConvertRules, I use
> > BindableConvention trait set to transform converted RelNode. The
> > QueryPlanner references to the implementation of SamzaSQL:
> >
> >
> > https://github.com/milinda/samza-sql/blob/master/samza-sql-planner/src
> > /main/java/org/apache/samza/sql/planner/QueryPlanner.java
> >
> > I replace the SamzaLogicalConvention.INSTANCE with the
> > BindableConvention.INSTANCE and remove the HepPlanner optimization.
> >
> > With the simple SQL test("select stream * from orders"), the volcano
> > planner always complains following errors:
> >
> > org.apache.calcite.plan.RelOptPlanner$CannotPlanException: Node
> > [rel#11:Subset#2.BINDABLE.[]] could not be implemented; planner state:
> >
> > Root: rel#11:Subset#2.BINDABLE.[]
> > Original rel:
> >
> > Sets:
> > Set#0, type: RecordType(INTEGER orderId, INTEGER productId)
> >     rel#6:Subset#0.ENUMERABLE.[], best=rel#3,
> importance=0.7290000000000001
> >              rel#3:EnumerableTableScan.ENUMERABLE.[](table=[orders]),
> > rowcount=100.0, cumulative cost={100.0 rows, 101.0 cpu, 0.0 io}
> >     rel#20:Subset#0.BINDABLE.[], best=null,
> > importance=0.36450000000000005 Set#1, type: RecordType(INTEGER orderId,
> INTEGER productId)
> >     rel#8:Subset#1.NONE.[], best=null, importance=0.81
> >
> >
> > rel#7:LogicalProject.NONE.[](input=rel#6:Subset#0.ENUMERABLE.[],orderI
> > d=$0,productId=$1),
> > rowcount=100.0, cumulative cost={inf}
> >     rel#17:Subset#1.BINDABLE.[], best=null, importance=0.405
> >
> >
> > rel#16:InterpretableConverter.BINDABLE.[](input=rel#8:Subset#1.NONE.[]
> > ),
> > rowcount=100.0, cumulative cost={inf}
> >
> >
> > rel#21:BindableProject.BINDABLE.[](input=rel#20:Subset#0.BINDABLE.[],o
> > rderId=$0,productId=$1),
> > rowcount=100.0, cumulative cost={inf}
> > Set#2, type: RecordType(INTEGER orderId, INTEGER productId)
> >     rel#10:Subset#2.NONE.[], best=null, importance=0.9
> >              rel#9:LogicalDelta.NONE.[](input=rel#8:Subset#1.NONE.[]),
> > rowcount=100.0, cumulative cost={inf}
> >     rel#11:Subset#2.BINDABLE.[], best=null, importance=1.0
> >
> >
> > rel#12:AbstractConverter.BINDABLE.[](input=rel#10:Subset#2.NONE.[],con
> > vention=BINDABLE,sort=[]),
> > rowcount=100.0, cumulative cost={inf}
> >
> >
> > rel#13:InterpretableConverter.BINDABLE.[](input=rel#10:Subset#2.NONE.[
> > ]),
> > rowcount=100.0, cumulative cost={inf}
> >
> >     at
> >
> org.apache.calcite.plan.volcano.RelSubset$CheapestPlanReplacer.visit(RelSubset.java:443)
> >     at
> >
> org.apache.calcite.plan.volcano.RelSubset.buildCheapestPlan(RelSubset.java:293)
> >     at
> >
> org.apache.calcite.plan.volcano.VolcanoPlanner.findBestExp(VolcanoPlanner.java:841)
> >     at
> > org.apache.calcite.tools.Programs$RuleSetProgram.run(Programs.java:334)
> >     at
> > org.apache.calcite.prepare.PlannerImpl.transform(PlannerImpl.java:290)
> >
> > I have no idea what to do with the runtime exceptions. Anything did I
> > forget ? Or Did I misuse the BindableConvention trait set ?
> >
> > Thanks.
> >
> >
> >
>
>
> --
> Milinda Pathirage
>
> PhD Student | Research Assistant
> School of Informatics and Computing | Data to Insight Center Indiana
> University
>
> twitter: milindalakmal
> skype: milinda.pathirage
> blog: http://milinda.pathirage.org
>

答复: [Calcite] Volcano planner fails to optimize

Posted by Zhangrucong <zh...@huawei.com>.
Hi Milinda,

Thanks for your help.

In Bindables.RULES, there is a BINDABLE_PROJECT_RULE for converting LogicalProject RelNode. So, I think it is not the reason of convention failure.
When I make the test table class implement TranslatableTable and FilterableTable interface, volcano planner works well. In addition to FilterableTable, ProjectableFilterable and Scannable interfaces also fix that exception.

But I have a little knowledge of the reason that the bindable rules require a translatable and filterable(or ProjectableFilterable, scannable) table.
Could you give me an explanation?

-----邮件原件-----
发件人: Milinda Pathirage [mailto:mpathira@umail.iu.edu] 
发送时间: 2016年6月23日 0:14
收件人: dev@calcite.apache.org
主题: Re: [Calcite] Volcano planner fails to optimize

Hi,

I think this is caused by missing LogicalProject converter rule. You can figure which rules are missing by going through the planner state. The error message says 'Node [rel#11:Subset#2.BINDABLE.[]] could not be implemented'.  That is because rel#11:Subset#2 has children whose inputs are still in NONE convention. For examples, rel#12:AbstractConverter's input 'rel#10:Subset#2' is still in NONE convention. This is because rel#9:LogicalDelta is missing its convention (or in NONE). Then if we look at the input to this delta, you can see that input's (rel#8:Subset#1) convention is also NONE. rel#8:Subset#1's convention is NONE because rel#7:LogicalProject has NONE convention.

Thanks
Milinda

On Tue, Jun 21, 2016 at 11:33 PM, Zhangrucong <zh...@huawei.com>
wrote:

> Hi everyone,
>
> I want to test calcite optimization of volcano planner with null cost 
> factory. To avoid implementing some RelNodes and ConvertRules, I use 
> BindableConvention trait set to transform converted RelNode. The 
> QueryPlanner references to the implementation of SamzaSQL:
>
>
> https://github.com/milinda/samza-sql/blob/master/samza-sql-planner/src
> /main/java/org/apache/samza/sql/planner/QueryPlanner.java
>
> I replace the SamzaLogicalConvention.INSTANCE with the 
> BindableConvention.INSTANCE and remove the HepPlanner optimization.
>
> With the simple SQL test("select stream * from orders"), the volcano 
> planner always complains following errors:
>
> org.apache.calcite.plan.RelOptPlanner$CannotPlanException: Node 
> [rel#11:Subset#2.BINDABLE.[]] could not be implemented; planner state:
>
> Root: rel#11:Subset#2.BINDABLE.[]
> Original rel:
>
> Sets:
> Set#0, type: RecordType(INTEGER orderId, INTEGER productId)
>     rel#6:Subset#0.ENUMERABLE.[], best=rel#3, importance=0.7290000000000001
>              rel#3:EnumerableTableScan.ENUMERABLE.[](table=[orders]),
> rowcount=100.0, cumulative cost={100.0 rows, 101.0 cpu, 0.0 io}
>     rel#20:Subset#0.BINDABLE.[], best=null, 
> importance=0.36450000000000005 Set#1, type: RecordType(INTEGER orderId, INTEGER productId)
>     rel#8:Subset#1.NONE.[], best=null, importance=0.81
>
>  
> rel#7:LogicalProject.NONE.[](input=rel#6:Subset#0.ENUMERABLE.[],orderI
> d=$0,productId=$1),
> rowcount=100.0, cumulative cost={inf}
>     rel#17:Subset#1.BINDABLE.[], best=null, importance=0.405
>
>  
> rel#16:InterpretableConverter.BINDABLE.[](input=rel#8:Subset#1.NONE.[]
> ),
> rowcount=100.0, cumulative cost={inf}
>
>  
> rel#21:BindableProject.BINDABLE.[](input=rel#20:Subset#0.BINDABLE.[],o
> rderId=$0,productId=$1),
> rowcount=100.0, cumulative cost={inf}
> Set#2, type: RecordType(INTEGER orderId, INTEGER productId)
>     rel#10:Subset#2.NONE.[], best=null, importance=0.9
>              rel#9:LogicalDelta.NONE.[](input=rel#8:Subset#1.NONE.[]),
> rowcount=100.0, cumulative cost={inf}
>     rel#11:Subset#2.BINDABLE.[], best=null, importance=1.0
>
>  
> rel#12:AbstractConverter.BINDABLE.[](input=rel#10:Subset#2.NONE.[],con
> vention=BINDABLE,sort=[]),
> rowcount=100.0, cumulative cost={inf}
>
>  
> rel#13:InterpretableConverter.BINDABLE.[](input=rel#10:Subset#2.NONE.[
> ]),
> rowcount=100.0, cumulative cost={inf}
>
>     at
> org.apache.calcite.plan.volcano.RelSubset$CheapestPlanReplacer.visit(RelSubset.java:443)
>     at
> org.apache.calcite.plan.volcano.RelSubset.buildCheapestPlan(RelSubset.java:293)
>     at
> org.apache.calcite.plan.volcano.VolcanoPlanner.findBestExp(VolcanoPlanner.java:841)
>     at
> org.apache.calcite.tools.Programs$RuleSetProgram.run(Programs.java:334)
>     at
> org.apache.calcite.prepare.PlannerImpl.transform(PlannerImpl.java:290)
>
> I have no idea what to do with the runtime exceptions. Anything did I 
> forget ? Or Did I misuse the BindableConvention trait set ?
>
> Thanks.
>
>
>


--
Milinda Pathirage

PhD Student | Research Assistant
School of Informatics and Computing | Data to Insight Center Indiana University

twitter: milindalakmal
skype: milinda.pathirage
blog: http://milinda.pathirage.org

Re: [Calcite] Volcano planner fails to optimize

Posted by Milinda Pathirage <mp...@umail.iu.edu>.
Hi,

I think this is caused by missing LogicalProject converter rule. You can
figure which rules are missing by going through the planner state. The
error message says 'Node [rel#11:Subset#2.BINDABLE.[]] could not be
implemented'.  That is because rel#11:Subset#2 has children whose inputs
are still in NONE convention. For examples, rel#12:AbstractConverter's input
'rel#10:Subset#2' is still in NONE convention. This is because
rel#9:LogicalDelta is missing its convention (or in NONE). Then if we look
at the input to this delta, you can see that input's (rel#8:Subset#1)
convention is also NONE. rel#8:Subset#1's convention is NONE because
rel#7:LogicalProject has NONE convention.

Thanks
Milinda

On Tue, Jun 21, 2016 at 11:33 PM, Zhangrucong <zh...@huawei.com>
wrote:

> Hi everyone,
>
> I want to test calcite optimization of volcano planner with null cost
> factory. To avoid implementing some RelNodes and ConvertRules, I use
> BindableConvention trait set to transform converted RelNode. The
> QueryPlanner references to the implementation of SamzaSQL:
>
>
> https://github.com/milinda/samza-sql/blob/master/samza-sql-planner/src/main/java/org/apache/samza/sql/planner/QueryPlanner.java
>
> I replace the SamzaLogicalConvention.INSTANCE with the
> BindableConvention.INSTANCE and remove the HepPlanner optimization.
>
> With the simple SQL test("select stream * from orders"), the volcano
> planner always complains following errors:
>
> org.apache.calcite.plan.RelOptPlanner$CannotPlanException: Node
> [rel#11:Subset#2.BINDABLE.[]] could not be implemented; planner state:
>
> Root: rel#11:Subset#2.BINDABLE.[]
> Original rel:
>
> Sets:
> Set#0, type: RecordType(INTEGER orderId, INTEGER productId)
>     rel#6:Subset#0.ENUMERABLE.[], best=rel#3, importance=0.7290000000000001
>              rel#3:EnumerableTableScan.ENUMERABLE.[](table=[orders]),
> rowcount=100.0, cumulative cost={100.0 rows, 101.0 cpu, 0.0 io}
>     rel#20:Subset#0.BINDABLE.[], best=null, importance=0.36450000000000005
> Set#1, type: RecordType(INTEGER orderId, INTEGER productId)
>     rel#8:Subset#1.NONE.[], best=null, importance=0.81
>
>  rel#7:LogicalProject.NONE.[](input=rel#6:Subset#0.ENUMERABLE.[],orderId=$0,productId=$1),
> rowcount=100.0, cumulative cost={inf}
>     rel#17:Subset#1.BINDABLE.[], best=null, importance=0.405
>
>  rel#16:InterpretableConverter.BINDABLE.[](input=rel#8:Subset#1.NONE.[]),
> rowcount=100.0, cumulative cost={inf}
>
>  rel#21:BindableProject.BINDABLE.[](input=rel#20:Subset#0.BINDABLE.[],orderId=$0,productId=$1),
> rowcount=100.0, cumulative cost={inf}
> Set#2, type: RecordType(INTEGER orderId, INTEGER productId)
>     rel#10:Subset#2.NONE.[], best=null, importance=0.9
>              rel#9:LogicalDelta.NONE.[](input=rel#8:Subset#1.NONE.[]),
> rowcount=100.0, cumulative cost={inf}
>     rel#11:Subset#2.BINDABLE.[], best=null, importance=1.0
>
>  rel#12:AbstractConverter.BINDABLE.[](input=rel#10:Subset#2.NONE.[],convention=BINDABLE,sort=[]),
> rowcount=100.0, cumulative cost={inf}
>
>  rel#13:InterpretableConverter.BINDABLE.[](input=rel#10:Subset#2.NONE.[]),
> rowcount=100.0, cumulative cost={inf}
>
>     at
> org.apache.calcite.plan.volcano.RelSubset$CheapestPlanReplacer.visit(RelSubset.java:443)
>     at
> org.apache.calcite.plan.volcano.RelSubset.buildCheapestPlan(RelSubset.java:293)
>     at
> org.apache.calcite.plan.volcano.VolcanoPlanner.findBestExp(VolcanoPlanner.java:841)
>     at
> org.apache.calcite.tools.Programs$RuleSetProgram.run(Programs.java:334)
>     at
> org.apache.calcite.prepare.PlannerImpl.transform(PlannerImpl.java:290)
>
> I have no idea what to do with the runtime exceptions. Anything did I
> forget ? Or Did I misuse the BindableConvention trait set ?
>
> Thanks.
>
>
>


-- 
Milinda Pathirage

PhD Student | Research Assistant
School of Informatics and Computing | Data to Insight Center
Indiana University

twitter: milindalakmal
skype: milinda.pathirage
blog: http://milinda.pathirage.org