use of io.crate.execution.engine.collect.CollectExpression in project crate by crate.
the class InputFactoryTest method testProcessGroupByProjectionSymbols.
@Test
public void testProcessGroupByProjectionSymbols() throws Exception {
// select x, y * 2 ... group by x, y * 2
// keys: [ in(0), in(1) + 10 ]
List<Symbol> keys = Arrays.asList(new InputColumn(0, DataTypes.LONG), add);
InputFactory.Context<CollectExpression<Row, ?>> ctx = factory.ctxForAggregations(txnCtx);
ctx.add(keys);
ArrayList<CollectExpression<Row, ?>> expressions = new ArrayList<>(ctx.expressions());
assertThat(expressions.size(), is(2));
// keyExpressions: [ in0, in1 ]
RowN row = new RowN(1L, 2L);
for (CollectExpression<Row, ?> expression : expressions) {
expression.setNextRow(row);
}
assertThat(expressions.get(0).value(), is(1L));
// raw input value
assertThat(expressions.get(1).value(), is(2L));
// inputs: [ x, add ]
List<Input<?>> inputs = ctx.topLevelInputs();
assertThat(inputs.size(), is(2));
assertThat(inputs.get(0).value(), is(1L));
// + 10
assertThat(inputs.get(1).value(), is(12));
}
Aggregations