Search in sources :

Example 1 with QueryThenFetch

use of io.crate.planner.node.dql.QueryThenFetch in project crate by crate.

the class SingleRowSubselectPlannerTest method testPlanSimpleSelectWithSingleRowSubSelectInWhereClause.

@Test
public void testPlanSimpleSelectWithSingleRowSubSelectInWhereClause() throws Exception {
    QueryThenFetch qtf = e.plan("select x from t1 where a = (select b from t2)");
    assertThat(qtf.subPlan(), instanceOf(MultiPhasePlan.class));
    MultiPhasePlan multiPhasePlan = (MultiPhasePlan) qtf.subPlan();
    assertThat(multiPhasePlan.dependencies().keySet(), contains(instanceOf(QueryThenFetch.class)));
}
Also used : QueryThenFetch(io.crate.planner.node.dql.QueryThenFetch) Test(org.junit.Test) CrateUnitTest(io.crate.test.integration.CrateUnitTest)

Example 2 with QueryThenFetch

use of io.crate.planner.node.dql.QueryThenFetch in project crate by crate.

the class SingleRowSubselectPlannerTest method testSingleRowSubSelectOfWhereInJoin.

@Test
public void testSingleRowSubSelectOfWhereInJoin() throws Exception {
    QueryThenFetch plan = e.plan("select * from users u1, users u2 where u1.name = (select 'Arthur')");
    assertThat(plan.subPlan(), instanceOf(NestedLoop.class));
    assertThat(((NestedLoop) plan.subPlan()).left(), instanceOf(MultiPhasePlan.class));
}
Also used : NestedLoop(io.crate.planner.node.dql.join.NestedLoop) QueryThenFetch(io.crate.planner.node.dql.QueryThenFetch) Test(org.junit.Test) CrateUnitTest(io.crate.test.integration.CrateUnitTest)

Example 3 with QueryThenFetch

use of io.crate.planner.node.dql.QueryThenFetch in project crate by crate.

the class FetchOperationIntegrationTest method testFetchProjection.

@SuppressWarnings("ConstantConditions")
@Test
public void testFetchProjection() throws Exception {
    setUpCharacters();
    PlanForNode plan = plan("select id, name, substr(name, 2) from characters order by id");
    QueryThenFetch qtf = ((QueryThenFetch) plan.plan);
    assertThat(qtf.subPlan(), instanceOf(Merge.class));
    Merge merge = (Merge) qtf.subPlan();
    assertThat(((FetchProjection) merge.mergePhase().projections().get(0)).nodeReaders(), notNullValue());
    assertThat(((FetchProjection) merge.mergePhase().projections().get(0)).readerIndices(), notNullValue());
    TestingBatchConsumer consumer = execute(plan);
    List<Object[]> result = consumer.getResult();
    assertThat(result.size(), is(2));
    assertThat(result.get(0).length, is(3));
    assertThat(result.get(0)[0], is(1));
    assertThat(result.get(0)[1], is(new BytesRef("Arthur")));
    assertThat(result.get(0)[2], is(new BytesRef("rthur")));
    assertThat(result.get(1)[0], is(2));
    assertThat(result.get(1)[1], is(new BytesRef("Ford")));
    assertThat(result.get(1)[2], is(new BytesRef("ord")));
}
Also used : QueryThenFetch(io.crate.planner.node.dql.QueryThenFetch) Merge(io.crate.planner.Merge) TestingBatchConsumer(io.crate.testing.TestingBatchConsumer) BytesRef(org.apache.lucene.util.BytesRef) Test(org.junit.Test)

Aggregations

QueryThenFetch (io.crate.planner.node.dql.QueryThenFetch)3 Test (org.junit.Test)3 CrateUnitTest (io.crate.test.integration.CrateUnitTest)2 Merge (io.crate.planner.Merge)1 NestedLoop (io.crate.planner.node.dql.join.NestedLoop)1 TestingBatchConsumer (io.crate.testing.TestingBatchConsumer)1 BytesRef (org.apache.lucene.util.BytesRef)1