use of io.crate.planner.node.dql.join.NestedLoop in project crate by crate.
the class NestedLoopConsumerTest method testLimitIncludesOffsetOnNestedLoopTopNProjection.
@Test
public void testLimitIncludesOffsetOnNestedLoopTopNProjection() throws Exception {
Merge merge = plan("select u1.name, u2.name from users u1, users u2 where u1.id = u2.id order by u1.name, u2.name limit 15 offset 10");
NestedLoop nl = (NestedLoop) merge.subPlan();
TopNProjection distTopN = (TopNProjection) nl.nestedLoopPhase().projections().get(1);
assertThat(distTopN.limit(), is(25));
assertThat(distTopN.offset(), is(0));
TopNProjection localTopN = (TopNProjection) merge.mergePhase().projections().get(0);
assertThat(localTopN.limit(), is(15));
assertThat(localTopN.offset(), is(10));
}
use of io.crate.planner.node.dql.join.NestedLoop in project crate by crate.
the class NestedLoopConsumerTest method testExplicitCrossJoinWithoutLimitOrOrderBy.
@Test
public void testExplicitCrossJoinWithoutLimitOrOrderBy() throws Exception {
QueryThenFetch plan = plan("select u1.name, u2.name from users u1 cross join users u2");
NestedLoop nestedLoop = (NestedLoop) plan.subPlan();
assertThat(nestedLoop.nestedLoopPhase().projections(), Matchers.contains(instanceOf(EvalProjection.class), instanceOf(FetchProjection.class)));
EvalProjection eval = ((EvalProjection) nestedLoop.nestedLoopPhase().projections().get(0));
assertThat(eval.outputs().size(), is(2));
MergePhase leftMerge = nestedLoop.nestedLoopPhase().leftMergePhase();
assertThat(leftMerge.projections().size(), is(0));
MergePhase rightMerge = nestedLoop.nestedLoopPhase().rightMergePhase();
assertThat(rightMerge.projections().size(), is(0));
}
use of io.crate.planner.node.dql.join.NestedLoop in project crate by crate.
the class NestedLoopConsumerTest method testAggregationOnCrossJoin.
@Test
public void testAggregationOnCrossJoin() throws Exception {
NestedLoop nl = plan("select min(u1.name) from users u1, users u2");
NestedLoopPhase nlPhase = nl.nestedLoopPhase();
assertThat(nlPhase.projections(), contains(instanceOf(EvalProjection.class), instanceOf(AggregationProjection.class), instanceOf(EvalProjection.class)));
AggregationProjection aggregationProjection = (AggregationProjection) nlPhase.projections().get(1);
Aggregation minAgg = aggregationProjection.aggregations().get(0);
assertThat(minAgg.fromStep(), is(Aggregation.Step.ITER));
assertThat(minAgg.toStep(), is(Aggregation.Step.FINAL));
}
use of io.crate.planner.node.dql.join.NestedLoop in project crate by crate.
the class InsertPlannerTest method testInsertFromSubQueryJoin.
@Test
public void testInsertFromSubQueryJoin() throws Exception {
NestedLoop nestedLoop = e.plan("insert into users (id, name) (select u1.id, u2.name from users u1 CROSS JOIN users u2)");
assertThat(nestedLoop.nestedLoopPhase().projections(), contains(instanceOf(EvalProjection.class), instanceOf(ColumnIndexWriterProjection.class)));
assertThat(nestedLoop.nestedLoopPhase().projections().get(1), instanceOf(ColumnIndexWriterProjection.class));
ColumnIndexWriterProjection projection = (ColumnIndexWriterProjection) nestedLoop.nestedLoopPhase().projections().get(1);
assertThat(projection.columnReferences().size(), is(2));
assertThat(projection.columnReferences().get(0).ident().columnIdent().fqn(), is("id"));
assertThat(projection.columnReferences().get(1).ident().columnIdent().fqn(), is("name"));
assertThat(((InputColumn) projection.ids().get(0)).index(), is(0));
assertThat(((InputColumn) projection.clusteredBy()).index(), is(0));
assertThat(projection.partitionedBySymbols().isEmpty(), is(true));
}
use of io.crate.planner.node.dql.join.NestedLoop 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));
}
Aggregations