Search in sources :

Example 21 with Collect

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));
}
Also used : Collect(io.crate.planner.node.dql.Collect) RoutedCollectPhase(io.crate.planner.node.dql.RoutedCollectPhase) Test(org.junit.Test) CrateUnitTest(io.crate.test.integration.CrateUnitTest)

Aggregations

Collect (io.crate.planner.node.dql.Collect)21 RoutedCollectPhase (io.crate.planner.node.dql.RoutedCollectPhase)18 CrateUnitTest (io.crate.test.integration.CrateUnitTest)17 Test (org.junit.Test)17 MergePhase (io.crate.planner.node.dql.MergePhase)9 Merge (io.crate.planner.Merge)8 Reference (io.crate.metadata.Reference)6 Symbol (io.crate.analyze.symbol.Symbol)3 InputColumn (io.crate.analyze.symbol.InputColumn)2 PositionalOrderBy (io.crate.planner.PositionalOrderBy)2 DeleteProjection (io.crate.planner.projection.DeleteProjection)2 MergeCountProjection (io.crate.planner.projection.MergeCountProjection)2 Projection (io.crate.planner.projection.Projection)2 WriterProjection (io.crate.planner.projection.WriterProjection)2 Function (io.crate.analyze.symbol.Function)1 ColumnIdent (io.crate.metadata.ColumnIdent)1 GeneratedReference (io.crate.metadata.GeneratedReference)1 ReferenceIdent (io.crate.metadata.ReferenceIdent)1 Routing (io.crate.metadata.Routing)1 DocTableInfo (io.crate.metadata.doc.DocTableInfo)1