@Override
    public ExecutionSchedule createExecutionSchedule(Session session, Collection<StageExecutionAndScheduler> stages)
    {
        if (stages.size() > getMaxStageCountForEagerScheduling(session)) {
            return new PhasedExecutionSchedule(stages);
        }
        else {
            return new AllAtOnceExecutionSchedule(stages);
        }
    }
@Test
    public void testCreateExecutionSchedule()
    {
        Session session = testSessionBuilder(new SessionPropertyManager(new SystemSessionProperties(
                new QueryManagerConfig(),
                new TaskManagerConfig(),
                new MemoryManagerConfig(),
                new FeaturesConfig().setMaxStageCountForEagerScheduling(5),
                new NodeMemoryConfig(),
                new WarningCollectorConfig(),
                new NodeSchedulerConfig(),
                new NodeSpillConfig(),
                new TracingConfig(),
                new CompilerConfig(),
                new HistoryBasedOptimizationConfig()))).build();
        AdaptivePhasedExecutionPolicy policy = new AdaptivePhasedExecutionPolicy();
        Collection<StageExecutionAndScheduler> schedulers = getStageExecutionAndSchedulers(4);
        assertTrue(policy.createExecutionSchedule(session, schedulers) instanceof AllAtOnceExecutionSchedule);
        schedulers = getStageExecutionAndSchedulers(5);
        assertTrue(policy.createExecutionSchedule(session, schedulers) instanceof AllAtOnceExecutionSchedule);
        schedulers = getStageExecutionAndSchedulers(6);
        assertTrue(policy.createExecutionSchedule(session, schedulers) instanceof PhasedExecutionSchedule);
    }