use of io.crate.planner.node.dql.join.NestedLoop in project crate by crate.
the class NestedLoopConsumerTest method testLeftSideIsBroadcastIfLeftTableIsSmaller.
@Test
public void testLeftSideIsBroadcastIfLeftTableIsSmaller() throws Exception {
Merge merge = plan("select users.name, u2.name from users, users_multi_pk u2 " + "where users.name = u2.name " + "order by users.name, u2.name ");
NestedLoop nl = (NestedLoop) merge.subPlan();
Collect collect = (Collect) nl.left();
assertThat(collect.collectPhase().distributionInfo().distributionType(), is(DistributionType.BROADCAST));
}
use of io.crate.planner.node.dql.join.NestedLoop in project crate by crate.
the class NestedLoopConsumerTest method testOrderByOnJoinCondition.
@Test
public void testOrderByOnJoinCondition() throws Exception {
NestedLoop nl = plan("select u1.name || u2.name from users u1, users u2 order by u1.name, u1.name || u2.name");
List<Symbol> orderBy = ((OrderedTopNProjection) nl.nestedLoopPhase().projections().get(0)).orderBy();
assertThat(orderBy, notNullValue());
assertThat(orderBy.size(), is(2));
assertThat(orderBy.get(0), isInputColumn(0));
assertThat(orderBy.get(1), isFunction("concat"));
}
use of io.crate.planner.node.dql.join.NestedLoop in project crate by crate.
the class NestedLoopConsumerTest method testJoinConditionInWhereClause.
@SuppressWarnings("unchecked")
@Test
public void testJoinConditionInWhereClause() throws Exception {
QueryThenFetch qtf = plan("select u1.floats, u2.name from users u1, users u2 where u1.name || u2.name = 'foobar'");
Merge merge = (Merge) qtf.subPlan();
NestedLoop nestedLoop = (NestedLoop) merge.subPlan();
assertThat(nestedLoop.nestedLoopPhase().projections(), Matchers.contains(instanceOf(FilterProjection.class), instanceOf(EvalProjection.class)));
EvalProjection eval = ((EvalProjection) nestedLoop.nestedLoopPhase().projections().get(1));
assertThat(eval.outputs().size(), is(3));
MergePhase localMergePhase = merge.mergePhase();
assertThat(localMergePhase.projections(), Matchers.contains(instanceOf(FetchProjection.class)));
FetchProjection fetchProjection = (FetchProjection) localMergePhase.projections().get(0);
assertThat(fetchProjection.outputs(), isSQL("FETCH(INPUT(0), doc.users._doc['floats']), INPUT(2)"));
}
use of io.crate.planner.node.dql.join.NestedLoop in project crate by crate.
the class NestedLoopConsumerTest method testLimitNotAppliedWhenFilteringRemains.
@Test
public void testLimitNotAppliedWhenFilteringRemains() throws Exception {
QueryThenFetch plan = plan("select * from users u1 " + "left join users u2 on u1.id=u2.id " + "left join users u3 on u2.id=u3.id " + "left join users u4 on u3.id=u4.id " + "where u1.name = u4.name " + "limit 10");
NestedLoopPhase nl = ((NestedLoop) plan.subPlan()).nestedLoopPhase();
assertThat(nl.projections().get(1), instanceOf(TopNProjection.class));
assertThat(((TopNProjection) nl.projections().get(1)).limit(), is(10));
nl = ((NestedLoop) ((NestedLoop) plan.subPlan()).left()).nestedLoopPhase();
assertThat(nl.projections().get(0), instanceOf(EvalProjection.class));
nl = ((NestedLoop) ((NestedLoop) ((NestedLoop) plan.subPlan()).left()).left()).nestedLoopPhase();
assertThat(nl.projections().get(0), instanceOf(EvalProjection.class));
}
use of io.crate.planner.node.dql.join.NestedLoop in project crate by crate.
the class NestedLoopConsumerTest method testNoNodePageSizeHintPushDownWithJoinCondition.
@Test
public void testNoNodePageSizeHintPushDownWithJoinCondition() throws Exception {
NestedLoop plan = plan("select * from information_schema.tables, information_schema .columns " + "where tables.table_schema = columns.table_schema " + "and tables.table_name = columns.table_name limit 10");
assertThat(((RoutedCollectPhase) ((Collect) plan.left()).collectPhase()).nodePageSizeHint(), nullValue());
assertThat(((RoutedCollectPhase) ((Collect) plan.right()).collectPhase()).nodePageSizeHint(), nullValue());
}
Aggregations