Search in sources :

Example 36 with InputColumn

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);
}
Also used : Aggregation(io.crate.expression.symbol.Aggregation) CountAggregation(io.crate.execution.engine.aggregation.impl.CountAggregation) Symbol(io.crate.expression.symbol.Symbol) InputColumn(io.crate.expression.symbol.InputColumn) StreamInput(org.elasticsearch.common.io.stream.StreamInput) BytesStreamOutput(org.elasticsearch.common.io.stream.BytesStreamOutput) Test(org.junit.Test)

Example 37 with InputColumn

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)");
}
Also used : Symbol(io.crate.expression.symbol.Symbol) DynamicReference(io.crate.expression.symbol.DynamicReference) FetchReference(io.crate.expression.symbol.FetchReference) Reference(io.crate.metadata.Reference) SymbolMatchers.isReference(io.crate.testing.SymbolMatchers.isReference) VoidReference(io.crate.expression.symbol.VoidReference) InputColumn(io.crate.expression.symbol.InputColumn) FetchReference(io.crate.expression.symbol.FetchReference) CrateDummyClusterServiceUnitTest(io.crate.test.integration.CrateDummyClusterServiceUnitTest) Test(org.junit.Test)

Example 38 with InputColumn

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)");
}
Also used : Symbol(io.crate.expression.symbol.Symbol) InputColumn(io.crate.expression.symbol.InputColumn) CrateDummyClusterServiceUnitTest(io.crate.test.integration.CrateDummyClusterServiceUnitTest) Test(org.junit.Test)

Example 39 with InputColumn

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));
}
Also used : FilterProjection(io.crate.execution.dsl.projection.FilterProjection) MergePhase(io.crate.execution.dsl.phases.MergePhase) Merge(io.crate.planner.Merge) Symbol(io.crate.expression.symbol.Symbol) InputColumn(io.crate.expression.symbol.InputColumn) OrderedTopNProjection(io.crate.execution.dsl.projection.OrderedTopNProjection) GroupProjection(io.crate.execution.dsl.projection.GroupProjection) FilterProjection(io.crate.execution.dsl.projection.FilterProjection) Projection(io.crate.execution.dsl.projection.Projection) TopNProjection(io.crate.execution.dsl.projection.TopNProjection) EvalProjection(io.crate.execution.dsl.projection.EvalProjection) CrateDummyClusterServiceUnitTest(io.crate.test.integration.CrateDummyClusterServiceUnitTest) Test(org.junit.Test) RandomizedTest(com.carrotsearch.randomizedtesting.RandomizedTest)

Example 40 with InputColumn

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);
}
Also used : Function(io.crate.expression.symbol.Function) MergePhase(io.crate.execution.dsl.phases.MergePhase) InputColumn(io.crate.expression.symbol.InputColumn) TopNProjection(io.crate.execution.dsl.projection.TopNProjection) Before(org.junit.Before)

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