use of io.crate.execution.dsl.projection.EvalProjection in project crate by crate.
the class Eval method addEvalProjection.
private ExecutionPlan addEvalProjection(PlannerContext plannerContext, ExecutionPlan executionPlan, Row params, SubQueryResults subQueryResults) {
PositionalOrderBy orderBy = executionPlan.resultDescription().orderBy();
PositionalOrderBy newOrderBy = null;
SubQueryAndParamBinder binder = new SubQueryAndParamBinder(params, subQueryResults);
List<Symbol> boundOutputs = Lists2.map(outputs, binder);
if (orderBy != null) {
newOrderBy = orderBy.tryMapToNewOutputs(source.outputs(), boundOutputs);
if (newOrderBy == null) {
executionPlan = Merge.ensureOnHandler(executionPlan, plannerContext);
}
}
InputColumns.SourceSymbols ctx = new InputColumns.SourceSymbols(Lists2.map(source.outputs(), binder));
executionPlan.addProjection(new EvalProjection(InputColumns.create(boundOutputs, ctx)), executionPlan.resultDescription().limit(), executionPlan.resultDescription().offset(), newOrderBy);
return executionPlan;
}
use of io.crate.execution.dsl.projection.EvalProjection in project crate by crate.
the class HashJoin method createEvalProjectionForDistributionJoinSymbol.
private List<Symbol> createEvalProjectionForDistributionJoinSymbol(Symbol firstJoinSymbol, List<Symbol> outputs, ExecutionPlan executionPlan) {
List<Symbol> projectionOutputs = new ArrayList<>(outputs.size() + 1);
projectionOutputs.addAll(outputs);
projectionOutputs.add(firstJoinSymbol);
EvalProjection evalProjection = new EvalProjection(InputColumns.create(projectionOutputs, new InputColumns.SourceSymbols(outputs)));
executionPlan.addProjection(evalProjection);
return projectionOutputs;
}
use of io.crate.execution.dsl.projection.EvalProjection in project crate by crate.
the class GroupByPlannerTest method testGroupByHaving.
@Test
public void testGroupByHaving() throws Exception {
var e = SQLExecutor.builder(clusterService, 2, RandomizedTest.getRandom(), List.of()).addTable(TableDefinitions.USER_TABLE_DEFINITION).build();
Merge distributedGroupByMerge = e.plan("select avg(date), name from users group by name having min(date) > '1970-01-01'");
Merge reduceMerge = (Merge) distributedGroupByMerge.subPlan();
CollectPhase collectPhase = ((Collect) reduceMerge.subPlan()).collectPhase();
assertThat(collectPhase.projections().size(), is(1));
assertThat(collectPhase.projections().get(0), instanceOf(GroupProjection.class));
MergePhase reducePhase = reduceMerge.mergePhase();
assertThat(reducePhase.projections().size(), is(3));
// grouping
assertThat(reducePhase.projections().get(0), instanceOf(GroupProjection.class));
GroupProjection groupProjection = (GroupProjection) reducePhase.projections().get(0);
assertThat(groupProjection.values().size(), is(2));
// filter the having clause
assertThat(reducePhase.projections().get(1), instanceOf(FilterProjection.class));
FilterProjection filterProjection = (FilterProjection) reducePhase.projections().get(1);
assertThat(reducePhase.projections().get(2), instanceOf(EvalProjection.class));
EvalProjection eval = (EvalProjection) reducePhase.projections().get(2);
assertThat(eval.outputs().get(0).valueType(), Is.<DataType>is(DataTypes.DOUBLE));
assertThat(eval.outputs().get(1).valueType(), Is.<DataType>is(DataTypes.STRING));
}
Aggregations