Search in sources :

Example 66 with Collect

use of io.crate.planner.node.dql.Collect in project crate by crate.

the class UpdatePlannerTest method testUpdateByQueryPlan.

@Test
public void testUpdateByQueryPlan() throws Exception {
    UpdatePlanner.Update plan = e.plan("update users set name='Vogon lyric fan'");
    Merge merge = (Merge) plan.createExecutionPlan.create(e.getPlannerContext(clusterService.state()), Row.EMPTY, SubQueryResults.EMPTY);
    Collect collect = (Collect) merge.subPlan();
    RoutedCollectPhase collectPhase = ((RoutedCollectPhase) collect.collectPhase());
    assertThat(collectPhase.where(), isSQL("true"));
    assertThat(collectPhase.projections().size(), is(1));
    assertThat(collectPhase.projections().get(0), instanceOf(UpdateProjection.class));
    assertThat(collectPhase.toCollect().size(), is(1));
    assertThat(collectPhase.toCollect().get(0), instanceOf(Reference.class));
    assertThat(((Reference) collectPhase.toCollect().get(0)).column().fqn(), is("_id"));
    UpdateProjection updateProjection = (UpdateProjection) collectPhase.projections().get(0);
    assertThat(updateProjection.uidSymbol(), instanceOf(InputColumn.class));
    assertThat(updateProjection.assignmentsColumns()[0], is("name"));
    Symbol symbol = updateProjection.assignments()[0];
    assertThat(symbol, isLiteral("Vogon lyric fan", DataTypes.STRING));
    MergePhase mergePhase = merge.mergePhase();
    assertThat(mergePhase.projections().size(), is(1));
    assertThat(mergePhase.projections().get(0), instanceOf(MergeCountProjection.class));
    assertThat(mergePhase.outputTypes().size(), is(1));
}
Also used : MergeCountProjection(io.crate.execution.dsl.projection.MergeCountProjection) MergePhase(io.crate.execution.dsl.phases.MergePhase) Collect(io.crate.planner.node.dql.Collect) Reference(io.crate.metadata.Reference) SymbolMatchers.isReference(io.crate.testing.SymbolMatchers.isReference) InputColumn(io.crate.expression.symbol.InputColumn) SelectSymbol(io.crate.expression.symbol.SelectSymbol) Symbol(io.crate.expression.symbol.Symbol) UpdatePlanner(io.crate.planner.consumer.UpdatePlanner) UpdateProjection(io.crate.execution.dsl.projection.UpdateProjection) RoutedCollectPhase(io.crate.execution.dsl.phases.RoutedCollectPhase) CrateDummyClusterServiceUnitTest(io.crate.test.integration.CrateDummyClusterServiceUnitTest) Test(org.junit.Test) RandomizedTest(com.carrotsearch.randomizedtesting.RandomizedTest)

Aggregations

Collect (io.crate.planner.node.dql.Collect)66 Test (org.junit.Test)57 CrateDummyClusterServiceUnitTest (io.crate.test.integration.CrateDummyClusterServiceUnitTest)55 RoutedCollectPhase (io.crate.execution.dsl.phases.RoutedCollectPhase)31 RandomizedTest (com.carrotsearch.randomizedtesting.RandomizedTest)27 GroupProjection (io.crate.execution.dsl.projection.GroupProjection)18 EvalProjection (io.crate.execution.dsl.projection.EvalProjection)16 Merge (io.crate.planner.Merge)16 MergePhase (io.crate.execution.dsl.phases.MergePhase)14 Projection (io.crate.execution.dsl.projection.Projection)12 Reference (io.crate.metadata.Reference)11 FilterProjection (io.crate.execution.dsl.projection.FilterProjection)10 TopNProjection (io.crate.execution.dsl.projection.TopNProjection)10 OrderedTopNProjection (io.crate.execution.dsl.projection.OrderedTopNProjection)9 CollectPhase (io.crate.execution.dsl.phases.CollectPhase)8 Symbol (io.crate.expression.symbol.Symbol)8 AggregationProjection (io.crate.execution.dsl.projection.AggregationProjection)6 QueryThenFetch (io.crate.planner.node.dql.QueryThenFetch)6 ColumnIndexWriterProjection (io.crate.execution.dsl.projection.ColumnIndexWriterProjection)5 InputColumn (io.crate.expression.symbol.InputColumn)5