LogicalNode rootNode = optimizer.optimize(plan);
PhysicalPlanner phyPlanner = new PhysicalPlannerImpl(conf,sm);
PhysicalExec exec = phyPlanner.createPlan(ctx, rootNode);
ExternalSortExec sort = null;
if (exec instanceof ProjectionExec) {
ProjectionExec projExec = (ProjectionExec) exec;
sort = projExec.getChild();
} else if (exec instanceof ExternalSortExec) {
sort = (ExternalSortExec) exec;
} else {
assertTrue(false);
}
SortSpec[] sortSpecs = sort.getPlan().getSortKeys();
RangeShuffleFileWriteExec idxStoreExec = new RangeShuffleFileWriteExec(ctx, sm, sort, sort.getSchema(),
sort.getSchema(), sortSpecs);
exec = idxStoreExec;
exec.init();
exec.next();
exec.close();