use of io.crate.execution.dsl.projection.ColumnIndexWriterProjection in project crate by crate.
the class InsertPlannerTest method testInsertFromSubQueryESGet.
@Test
public void testInsertFromSubQueryESGet() {
Merge merge = e.plan("insert into users (date, id, name) (select date, id, name from users where id=1)");
Collect queryAndFetch = (Collect) merge.subPlan();
PKLookupPhase collectPhase = ((PKLookupPhase) queryAndFetch.collectPhase());
assertThat(collectPhase.projections().size(), is(1));
assertThat(collectPhase.projections().get(0), instanceOf(ColumnIndexWriterProjection.class));
ColumnIndexWriterProjection projection = (ColumnIndexWriterProjection) collectPhase.projections().get(0);
assertThat(projection.columnReferencesExclPartition().size(), is(3));
assertThat(projection.columnReferencesExclPartition().get(0).column().fqn(), is("date"));
assertThat(projection.columnReferencesExclPartition().get(1).column().fqn(), is("id"));
assertThat(projection.columnReferencesExclPartition().get(2).column().fqn(), is("name"));
assertThat(((InputColumn) projection.ids().get(0)).index(), is(1));
assertThat(((InputColumn) projection.clusteredBy()).index(), is(1));
assertThat(projection.partitionedBySymbols().isEmpty(), is(true));
}
use of io.crate.execution.dsl.projection.ColumnIndexWriterProjection in project crate by crate.
the class InsertPlannerTest method testInsertFromSubQueryReduceOnCollectorGroupBy.
@Test
public void testInsertFromSubQueryReduceOnCollectorGroupBy() {
Merge merge = e.plan("insert into users (id, name) (select id, arbitrary(name) from users group by id)");
Collect collect = (Collect) merge.subPlan();
RoutedCollectPhase collectPhase = ((RoutedCollectPhase) collect.collectPhase());
assertThat(collectPhase.projections(), contains(instanceOf(GroupProjection.class), instanceOf(ColumnIndexWriterProjection.class)));
ColumnIndexWriterProjection columnIndexWriterProjection = (ColumnIndexWriterProjection) collectPhase.projections().get(1);
assertThat(columnIndexWriterProjection.columnReferencesExclPartition(), contains(isReference("id"), isReference("name")));
MergePhase mergePhase = merge.mergePhase();
assertThat(mergePhase.projections(), contains(instanceOf(MergeCountProjection.class)));
}
use of io.crate.execution.dsl.projection.ColumnIndexWriterProjection in project crate by crate.
the class InsertPlannerTest method testInsertFromSubQueryDistributedGroupByPartitioned.
@Test
public void testInsertFromSubQueryDistributedGroupByPartitioned() {
Merge planNode = e.plan("insert into parted_pks (id, date) (select id, date from users group by id, date)");
Merge groupBy = (Merge) planNode.subPlan();
MergePhase mergePhase = groupBy.mergePhase();
assertThat(mergePhase.projections(), contains(instanceOf(GroupProjection.class), instanceOf(EvalProjection.class), instanceOf(ColumnIndexWriterProjection.class)));
ColumnIndexWriterProjection projection = (ColumnIndexWriterProjection) mergePhase.projections().get(2);
assertThat(projection.primaryKeys().size(), is(2));
assertThat(projection.primaryKeys().get(0).fqn(), is("id"));
assertThat(projection.primaryKeys().get(1).fqn(), is("date"));
assertThat(projection.columnReferencesExclPartition().size(), is(1));
assertThat(projection.columnReferencesExclPartition().get(0).column().fqn(), is("id"));
assertThat(projection.partitionedBySymbols().size(), is(1));
assertThat(((InputColumn) projection.partitionedBySymbols().get(0)).index(), is(1));
assertNotNull(projection.clusteredByIdent());
assertThat(projection.clusteredByIdent().fqn(), is("id"));
assertThat(projection.tableIdent().fqn(), is("doc.parted_pks"));
MergePhase localMergeNode = planNode.mergePhase();
assertThat(localMergeNode.projections().size(), is(1));
assertThat(localMergeNode.projections().get(0), instanceOf(MergeCountProjection.class));
assertThat(localMergeNode.finalProjection().get().outputs().size(), is(1));
}
Aggregations