I originally wanted to do option 1, but it throws exception as the WindowRel that is generated from the WindowAggSplitterRule doesn't implement the Drill convention so I was thinking I have to do a two phase conversion.
I created a HepPlanner with only the WindowAggSplitterRule, and later passes that to the planner running Drill rules, and still getting the CannotPlanException similiarly before:
CannotPlanException: Node [rel#77:Subset#4.DRILL.[]] could not be implemented; planner state:
Root: rel#77:Subset#4.DRILL.[]
Original rel:
AbstractConverter(subset=[rel#77:Subset#4.DRILL.[]], convention=[DRILL], sort=[[]]): rowcount = 1.7976931348623157E308, cumulative cost = {inf}, id = 78
ProjectRel(subset=[rel#76:Subset#4.NONE.[]], EXPR$0=[CAST(CASE(>($0, 0), $1, null)):ANY]): rowcount = 1.7976931348623157E308, cumulative cost = {1.7976931348623157E308 rows, 1.7976931348623157E308 cpu, 0.0 io}, id = 75
ProjectRel(subset=[rel#74:Subset#3.NONE.[]], $0=[$1], $1=[$2]): rowcount = 1.7976931348623157E308, cumulative cost = {1.7976931348623157E308 rows, Infinity cpu, 0.0 io}, id = 73
WindowRel(subset=[rel#72:Subset#2.NONE.[]], window#0=[window(partition {0} order by [0 Ascending] rows between CURRENT ROW and CURRENT ROW aggs [COUNT($0), $SUM0($0)])]): rowcount = 1.7976931348623157E308, cumulative cost = {1.7976931348623157E308 rows, 1.7976931348623157E308 cpu, 0.0 io}, id = 71
ProjectRel(subset=[rel#70:Subset#1.NONE.[]], position_id=[$1]): rowcount = 100.0, cumulative cost = {100.0 rows, 100.0 cpu, 0.0 io}, id = 69
EnumerableTableAccessRel(subset=[rel#68:Subset#0.ENUMERABLE.[]], table=[[cp, employee.json]]): rowcount = 100.0, cumulative cost = {100.0 rows, 101.0 cpu, 0.0 io}, id = 49
Sets:
Set#0, type: DrillRecordRow
rel#68:Subset#0.ENUMERABLE.[], best=rel#49, importance=0.5904900000000001
rel#49:EnumerableTableAccessRel.ENUMERABLE.[](table=[cp, employee.json]), rowcount=100.0, cumulative cost={100.0 rows, 101.0 cpu, 0.0 io}
rel#86:AbstractConverter.ENUMERABLE.[](child=rel#85:Subset#0.DRILL.[],convention=ENUMERABLE,sort=[]), rowcount=100.0, cumulative cost={inf}
rel#85:Subset#0.DRILL.[], best=rel#92, importance=0.531441
rel#87:AbstractConverter.DRILL.[](child=rel#68:Subset#0.ENUMERABLE.[],convention=DRILL,sort=[]), rowcount=100.0, cumulative cost={inf}
rel#92:DrillScanRel.DRILL.[](table=[cp, employee.json]), rowcount=100.0, cumulative cost={100.0 rows, 101.0 cpu, 0.0 io}
Set#1, type: RecordType(ANY position_id)
rel#70:Subset#1.NONE.[], best=null, importance=0.6561
rel#69:ProjectRel.NONE.[](child=rel#68:Subset#0.ENUMERABLE.[],position_id=$1), rowcount=100.0, cumulative cost={inf}
rel#89:Subset#1.DRILL.[], best=rel#88, importance=0.32805
rel#90:AbstractConverter.DRILL.[](child=rel#70:Subset#1.NONE.[],convention=DRILL,sort=[]), rowcount=1.7976931348623157E308, cumulative cost={inf}
rel#88:DrillProjectRel.DRILL.[](child=rel#85:Subset#0.DRILL.[],position_id=$1), rowcount=100.0, cumulative cost={110.0 rows, 111.0 cpu, 0.0 io}
Set#2, type: RecordType(ANY position_id, BIGINT w0$o0, ANY w0$o1)
rel#72:Subset#2.NONE.[], best=null, importance=0.7290000000000001
rel#71:WindowRel.NONE.[](child=rel#70:Subset#1.NONE.[],window#0=window(partition {0} order by [0 Ascending] rows between CURRENT ROW and CURRENT ROW aggs [COUNT($0), $SUM0($0)])), rowcount=1.7976931348623157E308, cumulative cost={inf}
rel#82:Subset#2.DRILL.[], best=null, importance=0.81
rel#83:AbstractConverter.DRILL.[](child=rel#72:Subset#2.NONE.[],convention=DRILL,sort=[]), rowcount=1.7976931348623157E308, cumulative cost={inf}
Set#3, type: RecordType(BIGINT $0, ANY $1)
rel#74:Subset#3.NONE.[], best=null, importance=0.81
rel#73:ProjectRel.NONE.[](child=rel#72:Subset#2.NONE.[],$0=$1,$1=$2), rowcount=1.7976931348623157E308, cumulative cost={inf}
rel#79:Subset#3.DRILL.[], best=null, importance=0.9
rel#80:AbstractConverter.DRILL.[](child=rel#74:Subset#3.NONE.[],convention=DRILL,sort=[]), rowcount=1.7976931348623157E308, cumulative cost={inf}
rel#84:DrillProjectRel.DRILL.[](child=rel#82:Subset#2.DRILL.[],$0=$1,$1=$2), rowcount=1.7976931348623157E308, cumulative cost={inf}
Set#4, type: RecordType(ANY EXPR$0)
rel#76:Subset#4.NONE.[], best=null, importance=0.9
rel#75:ProjectRel.NONE.[](child=rel#74:Subset#3.NONE.[],EXPR$0=CAST(CASE(>($0, 0), $1, null)):ANY), rowcount=1.7976931348623157E308, cumulative cost={inf}
rel#77:Subset#4.DRILL.[], best=null, importance=1.0
rel#78:AbstractConverter.DRILL.[](child=rel#76:Subset#4.NONE.[],convention=DRILL,sort=[]), rowcount=1.7976931348623157E308, cumulative cost={inf}
rel#81:DrillProjectRel.DRILL.[](child=rel#79:Subset#3.DRILL.[],EXPR$0=CAST(CASE(>($0, 0), $1, null)):ANY), rowcount=1.7976931348623157E308, cumulative cost={inf}