use of io.crate.planner.node.dql.Collect in project crate by crate.
the class InsertPlannerTest method testInsertFromQueryWithPartitionedColumn.
@Test
public void testInsertFromQueryWithPartitionedColumn() {
Merge planNode = e.plan("insert into users (id, date) (select id, date from parted_pks)");
Collect queryAndFetch = (Collect) planNode.subPlan();
RoutedCollectPhase collectPhase = ((RoutedCollectPhase) queryAndFetch.collectPhase());
List<Symbol> toCollect = collectPhase.toCollect();
assertThat(toCollect.size(), is(2));
assertThat(toCollect.get(0), isReference("_doc['id']"));
assertThat(toCollect.get(1), equalTo(new Reference(new ReferenceIdent(new RelationName(Schemas.DOC_SCHEMA_NAME, "parted_pks"), "date"), RowGranularity.PARTITION, DataTypes.TIMESTAMPZ, ColumnPolicy.DYNAMIC, IndexType.PLAIN, true, true, 3, null)));
}
use of io.crate.planner.node.dql.Collect in project crate by crate.
the class InsertPlannerTest method test_insert_select_distinct.
@Test
public void test_insert_select_distinct() throws Exception {
Merge merge = e.plan("insert into users (id) (select distinct id from users)");
Collect collect = (Collect) merge.subPlan();
List<Projection> projections = collect.collectPhase().projections();
assertThat(projections, contains(instanceOf(GroupProjection.class), instanceOf(ColumnIndexWriterProjection.class)));
assertThat(projections.get(0).requiredGranularity(), is(RowGranularity.SHARD));
}
use of io.crate.planner.node.dql.Collect in project crate by crate.
the class InsertPlannerTest method testInsertFromSubQueryReduceOnCollectorGroupByWithCast.
@Test
public void testInsertFromSubQueryReduceOnCollectorGroupByWithCast() {
Merge merge = e.plan("insert into users (id, name) (select id, count(*) from users group by id)");
Collect nonDistributedGroupBy = (Collect) merge.subPlan();
RoutedCollectPhase collectPhase = ((RoutedCollectPhase) nonDistributedGroupBy.collectPhase());
assertThat(collectPhase.projections(), contains(instanceOf(GroupProjection.class), instanceOf(EvalProjection.class), instanceOf(ColumnIndexWriterProjection.class)));
EvalProjection collectTopN = (EvalProjection) collectPhase.projections().get(1);
assertThat(collectTopN.outputs(), contains(isInputColumn(0), isFunction(ImplicitCastFunction.NAME, List.of(DataTypes.LONG, DataTypes.STRING))));
ColumnIndexWriterProjection columnIndexWriterProjection = (ColumnIndexWriterProjection) collectPhase.projections().get(2);
assertThat(columnIndexWriterProjection.columnReferencesExclPartition(), contains(isReference("id"), isReference("name")));
MergePhase mergePhase = merge.mergePhase();
assertThat(mergePhase.projections(), contains(instanceOf(MergeCountProjection.class)));
}
use of io.crate.planner.node.dql.Collect in project crate by crate.
the class InsertPlannerTest method testInsertFromSubQueryWithLimit.
@Test
public void testInsertFromSubQueryWithLimit() {
QueryThenFetch qtf = e.plan("insert into users (date, id, name) (select date, id, name from users limit 10)");
Merge merge = (Merge) qtf.subPlan();
Collect collect = (Collect) merge.subPlan();
assertThat(collect.collectPhase().projections(), contains(instanceOf(TopNProjection.class)));
assertThat(merge.mergePhase().projections(), contains(instanceOf(TopNProjection.class), instanceOf(FetchProjection.class), instanceOf(ColumnIndexWriterProjection.class)));
}
use of io.crate.planner.node.dql.Collect in project crate by crate.
the class GlobalAggregatePlannerTest method test_aggregate_on_virtual_table_uses_shard_projections_if_possible.
@Test
public void test_aggregate_on_virtual_table_uses_shard_projections_if_possible() {
Collect plan = e.plan("select sum(x) from (select x from t1) t");
List<Projection> projections = plan.collectPhase().projections();
assertThat(projections, contains(instanceOf(AggregationProjection.class), instanceOf(AggregationProjection.class)));
assertThat(projections.get(0).requiredGranularity(), is(RowGranularity.SHARD));
}
Aggregations