Search in sources :

Example 61 with InputColumn

use of io.crate.expression.symbol.InputColumn in project crate by crate.

the class InsertPlannerTest method testGroupByHavingInsertInto.

@Test
public void testGroupByHavingInsertInto() {
    Merge planNode = e.plan("insert into users (id, name) (select name, count(*) from users group by name having count(*) > 3)");
    Merge groupByNode = (Merge) planNode.subPlan();
    MergePhase mergePhase = groupByNode.mergePhase();
    assertThat(mergePhase.projections(), contains(instanceOf(GroupProjection.class), instanceOf(FilterProjection.class), instanceOf(EvalProjection.class), instanceOf(ColumnIndexWriterProjection.class)));
    FilterProjection filterProjection = (FilterProjection) mergePhase.projections().get(1);
    assertThat(filterProjection.outputs().size(), is(2));
    assertThat(filterProjection.outputs().get(0), instanceOf(InputColumn.class));
    assertThat(filterProjection.outputs().get(1), instanceOf(InputColumn.class));
    InputColumn inputColumn = (InputColumn) filterProjection.outputs().get(0);
    assertThat(inputColumn.index(), is(0));
    inputColumn = (InputColumn) filterProjection.outputs().get(1);
    assertThat(inputColumn.index(), is(1));
    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));
}
Also used : MergeCountProjection(io.crate.execution.dsl.projection.MergeCountProjection) FilterProjection(io.crate.execution.dsl.projection.FilterProjection) MergePhase(io.crate.execution.dsl.phases.MergePhase) InputColumn(io.crate.expression.symbol.InputColumn) SymbolMatchers.isInputColumn(io.crate.testing.SymbolMatchers.isInputColumn) CrateDummyClusterServiceUnitTest(io.crate.test.integration.CrateDummyClusterServiceUnitTest) Test(org.junit.Test)

Aggregations

InputColumn (io.crate.expression.symbol.InputColumn)61 Test (org.junit.Test)47 Symbol (io.crate.expression.symbol.Symbol)38 CrateDummyClusterServiceUnitTest (io.crate.test.integration.CrateDummyClusterServiceUnitTest)25 Reference (io.crate.metadata.Reference)15 BytesStreamOutput (org.elasticsearch.common.io.stream.BytesStreamOutput)11 StreamInput (org.elasticsearch.common.io.stream.StreamInput)11 MergePhase (io.crate.execution.dsl.phases.MergePhase)10 GroupProjection (io.crate.execution.dsl.projection.GroupProjection)10 FilterProjection (io.crate.execution.dsl.projection.FilterProjection)9 OrderedTopNProjection (io.crate.execution.dsl.projection.OrderedTopNProjection)9 Aggregation (io.crate.expression.symbol.Aggregation)9 Function (io.crate.expression.symbol.Function)9 ArrayList (java.util.ArrayList)9 TopNProjection (io.crate.execution.dsl.projection.TopNProjection)8 RandomizedTest (com.carrotsearch.randomizedtesting.RandomizedTest)7 Row (io.crate.data.Row)7 EvalProjection (io.crate.execution.dsl.projection.EvalProjection)7 Projection (io.crate.execution.dsl.projection.Projection)7 CountAggregation (io.crate.execution.engine.aggregation.impl.CountAggregation)7