use of io.crate.expression.symbol.InputColumn in project crate by crate.
the class GroupProjectionTest method testStreaming.
@Test
public void testStreaming() throws Exception {
List<Symbol> keys = List.of(new InputColumn(0, DataTypes.STRING), new InputColumn(1, DataTypes.SHORT));
List<Aggregation> aggregations = List.of();
GroupProjection p = new GroupProjection(keys, aggregations, AggregateMode.ITER_FINAL, RowGranularity.CLUSTER);
BytesStreamOutput out = new BytesStreamOutput();
Projection.toStream(p, out);
StreamInput in = out.bytes().streamInput();
GroupProjection p2 = (GroupProjection) Projection.fromStream(in);
assertEquals(p, p2);
}
use of io.crate.expression.symbol.InputColumn in project crate by crate.
the class SymbolPrinterTest method testPrintFetchRefs.
@Test
public void testPrintFetchRefs() throws Exception {
Symbol field = sqlExpressions.asSymbol("bar");
assertThat(field, isReference("bar"));
Reference ref = (Reference) field;
FetchReference fetchRef = new FetchReference(new InputColumn(0, field.valueType()), ref);
assertPrint(fetchRef, "FETCH(INPUT(0), doc.formatter.bar)");
}
use of io.crate.expression.symbol.InputColumn in project crate by crate.
the class SymbolPrinterTest method testPrintInputColumn.
@Test
public void testPrintInputColumn() throws Exception {
Symbol inputCol = new InputColumn(42);
assertPrint(inputCol, "INPUT(42)");
}
use of io.crate.expression.symbol.InputColumn in project crate by crate.
the class GroupByPlannerTest method testGroupByWithHavingAndNoLimit.
@Test
public void testGroupByWithHavingAndNoLimit() throws Exception {
var e = SQLExecutor.builder(clusterService, 2, RandomizedTest.getRandom(), List.of()).addTable(TableDefinitions.USER_TABLE_DEFINITION).build();
Merge planNode = e.plan("select count(*), name from users group by name having count(*) > 1");
Merge reducerMerge = (Merge) planNode.subPlan();
// reducer
MergePhase mergePhase = reducerMerge.mergePhase();
// group projection
// outputs: name, count(*)
Projection projection = mergePhase.projections().get(1);
assertThat(projection, instanceOf(FilterProjection.class));
FilterProjection filterProjection = (FilterProjection) projection;
Symbol countArgument = ((Function) filterProjection.query()).arguments().get(0);
assertThat(countArgument, instanceOf(InputColumn.class));
// pointing to second output from group projection
assertThat(((InputColumn) countArgument).index(), is(1));
assertThat(mergePhase.outputTypes().get(0), equalTo(DataTypes.LONG));
assertThat(mergePhase.outputTypes().get(1), equalTo(DataTypes.STRING));
mergePhase = planNode.mergePhase();
assertThat(mergePhase.outputTypes().get(0), equalTo(DataTypes.LONG));
assertThat(mergePhase.outputTypes().get(1), equalTo(DataTypes.STRING));
}
use of io.crate.expression.symbol.InputColumn in project crate by crate.
the class JoinPhaseTest method setup.
@Before
public void setup() {
topNProjection = new TopNProjection(10, 0, Collections.emptyList());
jobId = UUID.randomUUID();
mp1 = new MergePhase(jobId, 2, "merge", 1, 1, Collections.emptyList(), List.of(DataTypes.STRING), List.of(), DistributionInfo.DEFAULT_BROADCAST, null);
mp2 = new MergePhase(jobId, 3, "merge", 1, 1, Collections.emptyList(), List.of(DataTypes.STRING), List.of(), DistributionInfo.DEFAULT_BROADCAST, null);
joinCondition = new Function(EqOperator.SIGNATURE, List.of(new InputColumn(0, DataTypes.STRING), new InputColumn(1, DataTypes.STRING)), EqOperator.RETURN_TYPE);
}
Aggregations