use of io.crate.planner.node.dql.Collect in project crate by crate.
the class SubQueryPlannerTest method testNestedSimpleSelectContainsFilterProjectionForWhereClause.
@Test
public void testNestedSimpleSelectContainsFilterProjectionForWhereClause() throws Exception {
QueryThenFetch qtf = e.plan("select x, i from " + " (select x, i from t1 order by x asc limit 10) ti " + "where ti.x = 10 " + "order by x desc limit 3");
Collect collect = (Collect) qtf.subPlan();
List<Projection> projections = collect.collectPhase().projections();
assertThat(projections, Matchers.hasItem(instanceOf(FilterProjection.class)));
}
use of io.crate.planner.node.dql.Collect in project crate by crate.
the class GlobalAggregateConsumer method globalAggregates.
/**
* Create a Merge(Collect) plan.
*
* iter->partial aggregations on use {@code projectionGranularity} granularity
*/
private static Plan globalAggregates(Functions functions, QueriedTableRelation table, ConsumerContext context, RowGranularity projectionGranularity) {
QuerySpec querySpec = table.querySpec();
if (querySpec.groupBy().isPresent() || !querySpec.hasAggregates()) {
return null;
}
// global aggregate: collect and partial aggregate on C and final agg on H
Planner.Context plannerContext = context.plannerContext();
validateAggregationOutputs(table.tableRelation(), querySpec.outputs());
ProjectionBuilder projectionBuilder = new ProjectionBuilder(functions, querySpec);
SplitPoints splitPoints = projectionBuilder.getSplitPoints();
AggregationProjection ap = projectionBuilder.aggregationProjection(splitPoints.leaves(), splitPoints.aggregates(), Aggregation.Step.ITER, Aggregation.Step.PARTIAL, projectionGranularity);
RoutedCollectPhase collectPhase = RoutedCollectPhase.forQueriedTable(plannerContext, table, splitPoints.leaves(), ImmutableList.of(ap));
Collect collect = new Collect(collectPhase, TopN.NO_LIMIT, 0, ap.outputs().size(), 1, null);
AggregationProjection aggregationProjection = projectionBuilder.aggregationProjection(splitPoints.aggregates(), splitPoints.aggregates(), Aggregation.Step.PARTIAL, Aggregation.Step.FINAL, RowGranularity.CLUSTER);
List<Projection> postAggregationProjections = createPostAggregationProjections(querySpec, splitPoints, plannerContext);
postAggregationProjections.add(0, aggregationProjection);
return createMerge(collect, plannerContext, postAggregationProjections);
}
use of io.crate.planner.node.dql.Collect in project crate by crate.
the class UpdateConsumer method createPlan.
private static Plan createPlan(Planner.Context plannerContext, Routing routing, TableInfo tableInfo, Reference idReference, Projection updateProjection, WhereClause whereClause) {
RoutedCollectPhase collectPhase = new RoutedCollectPhase(plannerContext.jobId(), plannerContext.nextExecutionPhaseId(), "collect", routing, tableInfo.rowGranularity(), Collections.singletonList(idReference), Collections.singletonList(updateProjection), whereClause, DistributionInfo.DEFAULT_BROADCAST);
Collect collect = new Collect(collectPhase, TopN.NO_LIMIT, 0, 1, 1, null);
return Merge.ensureOnHandler(collect, plannerContext, Collections.singletonList(MergeCountProjection.INSTANCE));
}
use of io.crate.planner.node.dql.Collect in project crate by crate.
the class CopyToPlannerTest method testCopyToWithPartitionedGeneratedColumn.
@Test
public void testCopyToWithPartitionedGeneratedColumn() throws Exception {
// test that generated partition column is NOT exported
Merge plan = e.plan("copy parted_generated to directory '/tmp'");
Collect innerPlan = (Collect) plan.subPlan();
RoutedCollectPhase node = ((RoutedCollectPhase) innerPlan.collectPhase());
WriterProjection projection = (WriterProjection) node.projections().get(0);
assertThat(projection.overwrites().size(), is(0));
}
use of io.crate.planner.node.dql.Collect in project crate by crate.
the class CopyToPlannerTest method testCopyToWithColumnsReferenceRewrite.
@Test
public void testCopyToWithColumnsReferenceRewrite() throws Exception {
Merge plan = e.plan("copy users (name) to directory '/tmp'");
Collect innerPlan = (Collect) plan.subPlan();
RoutedCollectPhase node = ((RoutedCollectPhase) innerPlan.collectPhase());
Reference nameRef = (Reference) node.toCollect().get(0);
assertThat(nameRef.ident().columnIdent().name(), is(DocSysColumns.DOC.name()));
assertThat(nameRef.ident().columnIdent().path().get(0), is("name"));
}
Aggregations