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)));
}
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));
}
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")));
}
Aggregations