use of io.crate.planner.node.dql.Collect in project crate by crate.
the class InsertPlannerTest method testInsertFromSubQueryESGet.
@Test
public void testInsertFromSubQueryESGet() throws Exception {
// doesn't use ESGetNode but CollectNode.
// Round-trip to handler can be skipped by writing from the shards directly
Merge merge = e.plan("insert into users (date, id, name) (select date, id, name from users where id=1)");
Collect queryAndFetch = (Collect) merge.subPlan();
RoutedCollectPhase collectPhase = ((RoutedCollectPhase) 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.columnReferences().size(), is(3));
assertThat(projection.columnReferences().get(0).ident().columnIdent().fqn(), is("date"));
assertThat(projection.columnReferences().get(1).ident().columnIdent().fqn(), is("id"));
assertThat(projection.columnReferences().get(2).ident().columnIdent().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));
}
Aggregations