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));
}
Aggregations