private static void handleProjections(OSelectExecutionPlan result, QueryPlanningInfo info, OCommandContext ctx,
boolean profilingEnabled) {
if (!info.projectionsCalculated && info.projection != null) {
if (info.preAggregateProjection != null) {
result.chain(new ProjectionCalculationStep(info.preAggregateProjection, ctx, profilingEnabled));
}
if (info.aggregateProjection != null) {
result.chain(new AggregateProjectionCalculationStep(info.aggregateProjection, info.groupBy, ctx, profilingEnabled));
if (isCountOnly(info) && info.groupBy == null) {
result.chain(new GuaranteeEmptyCountStep(info.aggregateProjection.getItems().get(0), ctx, profilingEnabled));
}
}
result.chain(new ProjectionCalculationStep(info.projection, ctx, profilingEnabled));
info.projectionsCalculated = true;
}
}