use of io.crate.planner.node.dql.join.NestedLoop in project crate by crate.
the class SelectPlannerTest method testOuterJoinToInnerJoinRewrite.
@Test
public void testOuterJoinToInnerJoinRewrite() throws Exception {
QueryThenFetch qtf = e.plan("select u1.text, u2.text " + "from users u1 left join users u2 on u1.id = u2.id " + "where u2.name = 'Arthur'" + "and u2.id > 1 ");
NestedLoop nl = (NestedLoop) qtf.subPlan();
assertThat(nl.nestedLoopPhase().joinType(), is(JoinType.INNER));
Collect rightCM = (Collect) nl.right();
assertThat(((RoutedCollectPhase) rightCM.collectPhase()).whereClause().query(), isSQL("((doc.users.name = 'Arthur') AND (doc.users.id > 1))"));
// doesn't contain "name" because whereClause is pushed down,
// but still contains "id" because it is in the joinCondition
assertThat(rightCM.collectPhase().toCollect(), contains(isReference("_fetchid"), isReference("id")));
}
use of io.crate.planner.node.dql.join.NestedLoop in project crate by crate.
the class SelectPlannerTest method test3TableJoinQuerySplitting.
@Test
public void test3TableJoinQuerySplitting() throws Exception {
QueryThenFetch qtf = e.plan("select" + " u1.id as u1, " + " u2.id as u2, " + " u3.id as u3 " + "from " + " users u1," + " users u2," + " users u3 " + "where " + " u1.name = 'Arthur'" + " and u2.id = u1.id" + " and u2.name = u1.name");
NestedLoop outerNl = (NestedLoop) qtf.subPlan();
NestedLoop innerNl = (NestedLoop) outerNl.left();
assertThat(((FilterProjection) innerNl.nestedLoopPhase().projections().get(0)).query(), isSQL("((INPUT(2) = INPUT(0)) AND (INPUT(3) = INPUT(1)))"));
}
use of io.crate.planner.node.dql.join.NestedLoop in project crate by crate.
the class NestedLoopConsumerTest method testNodePageSizePushDown.
@Test
public void testNodePageSizePushDown() throws Exception {
NestedLoop plan = plan("select u1.name from users u1, users u2 order by 1 limit 1000");
RoutedCollectPhase cpL = ((RoutedCollectPhase) ((Collect) plan.left()).collectPhase());
assertThat(cpL.nodePageSizeHint(), is(750));
RoutedCollectPhase cpR = ((RoutedCollectPhase) ((Collect) plan.right()).collectPhase());
assertThat(cpR.nodePageSizeHint(), is(750));
}
use of io.crate.planner.node.dql.join.NestedLoop in project crate by crate.
the class NestedLoopConsumerTest method testFetch.
@Test
public void testFetch() throws Exception {
QueryThenFetch plan = plan("select u1.name, u2.id from users u1, users u2 order by 2");
NestedLoopPhase nlp = ((NestedLoop) plan.subPlan()).nestedLoopPhase();
assertThat(nlp.projections().get(0).outputs(), isSQL("INPUT(1), INPUT(0)"));
}
use of io.crate.planner.node.dql.join.NestedLoop in project crate by crate.
the class NestedLoopConsumerTest method testRefsAreNotConvertedToSourceLookups.
@Test
public void testRefsAreNotConvertedToSourceLookups() throws Exception {
Merge merge = plan("select u1.name from users u1, users u2 where u1.id = u2.id order by 1");
NestedLoop nl = (NestedLoop) merge.subPlan();
CollectPhase cpLeft = ((Collect) nl.left()).collectPhase();
assertThat(cpLeft.toCollect(), contains(isReference("id"), isReference("name")));
CollectPhase cpRight = ((Collect) nl.right()).collectPhase();
assertThat(cpRight.toCollect(), contains(isReference("id")));
}
Aggregations