use of io.crate.analyze.symbol.InputColumn in project crate by crate.
the class OrderedTopNProjectionTest method testStreaming.
@Test
public void testStreaming() throws Exception {
Projection p = new OrderedTopNProjection(10, 20, Collections.singletonList(Literal.of("foobar")), Collections.singletonList(new InputColumn(0, DataTypes.STRING)), new boolean[] { true }, new Boolean[] { null });
BytesStreamOutput out = new BytesStreamOutput();
Projection.toStream(p, out);
StreamInput in = StreamInput.wrap(out.bytes());
Projection projection = Projection.fromStream(in);
assertThat(projection, equalTo(p));
}
use of io.crate.analyze.symbol.InputColumn in project crate by crate.
the class OrderByPositionVisitorTest method testSymbols.
@Test
public void testSymbols() throws Exception {
Reference ref = TestingHelpers.createReference("column", DataTypes.STRING);
int[] orderByPositions = OrderByPositionVisitor.orderByPositions(ImmutableList.of(ref, new InputColumn(1), new InputColumn(0)), ImmutableList.of(ref, Literal.of(1)));
assertArrayEquals(new int[] { 0, 1, 0 }, orderByPositions);
}
use of io.crate.analyze.symbol.InputColumn in project crate by crate.
the class OrderByPositionVisitorTest method testSymbolNotContained.
@Test
public void testSymbolNotContained() throws Exception {
expectedException.expect(IllegalArgumentException.class);
expectedException.expectMessage("Cannot sort by: other - not part of source symbols");
Reference ref = TestingHelpers.createReference("column", DataTypes.STRING);
OrderByPositionVisitor.orderByPositions(ImmutableList.of(ref, new InputColumn(1), TestingHelpers.createReference("other", DataTypes.LONG)), ImmutableList.of(ref, Literal.BOOLEAN_FALSE));
}
use of io.crate.analyze.symbol.InputColumn in project crate by crate.
the class InsertPlannerTest method testGroupByHavingInsertInto.
@Test
public void testGroupByHavingInsertInto() throws Exception {
Merge planNode = e.plan("insert into users (id, name) (select name, count(*) from users group by name having count(*) > 3)");
DistributedGroupBy groupByNode = (DistributedGroupBy) planNode.subPlan();
MergePhase mergePhase = groupByNode.reducerMergeNode();
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));
}
use of io.crate.analyze.symbol.InputColumn in project crate by crate.
the class AggregatorTest method testAggregationFromPartial.
@Test
public void testAggregationFromPartial() {
Aggregation aggregation = Aggregation.finalAggregation(countImpl.info(), Collections.<Symbol>singletonList(new InputColumn(0)), Aggregation.Step.PARTIAL);
Input dummyInput = new Input() {
CountAggregation.LongState state = new CountAggregation.LongState(10L);
@Override
public Object value() {
return state;
}
};
Aggregator aggregator = new Aggregator(RAM_ACCOUNTING_CONTEXT, aggregation, countImpl, dummyInput);
Object state = aggregator.prepareState();
state = aggregator.processRow(state);
state = aggregator.processRow(state);
Object result = aggregator.finishCollect(state);
assertThat((Long) result, is(20L));
}
Aggregations