Search in sources :

Example 11 with NestedLoop

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));
}
Also used : NestedLoop(io.crate.planner.node.dql.join.NestedLoop) Test(org.junit.Test) CrateUnitTest(io.crate.test.integration.CrateUnitTest)

Example 12 with NestedLoop

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"));
}
Also used : NestedLoop(io.crate.planner.node.dql.join.NestedLoop) Symbol(io.crate.analyze.symbol.Symbol) Test(org.junit.Test) CrateUnitTest(io.crate.test.integration.CrateUnitTest)

Example 13 with NestedLoop

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)"));
}
Also used : NestedLoop(io.crate.planner.node.dql.join.NestedLoop) Test(org.junit.Test) CrateUnitTest(io.crate.test.integration.CrateUnitTest)

Example 14 with NestedLoop

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));
}
Also used : NestedLoop(io.crate.planner.node.dql.join.NestedLoop) NestedLoopPhase(io.crate.planner.node.dql.join.NestedLoopPhase) Test(org.junit.Test) CrateUnitTest(io.crate.test.integration.CrateUnitTest)

Example 15 with NestedLoop

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());
}
Also used : NestedLoop(io.crate.planner.node.dql.join.NestedLoop) Test(org.junit.Test) CrateUnitTest(io.crate.test.integration.CrateUnitTest)

Aggregations

NestedLoop (io.crate.planner.node.dql.join.NestedLoop)20 CrateUnitTest (io.crate.test.integration.CrateUnitTest)20 Test (org.junit.Test)20 NestedLoopPhase (io.crate.planner.node.dql.join.NestedLoopPhase)3 Aggregation (io.crate.analyze.symbol.Aggregation)1 Symbol (io.crate.analyze.symbol.Symbol)1 QueryThenFetch (io.crate.planner.node.dql.QueryThenFetch)1