Search in sources :

Example 1 with QueryPlanFragments

use of org.apache.drill.exec.proto.UserProtos.QueryPlanFragments in project drill by axbaretto.

the class DrillSeparatePlanningTest method testMultiMinorFragmentComplexQuery.

@Test(timeout = 60_000)
public void testMultiMinorFragmentComplexQuery() throws Exception {
    final String query = "SELECT dir0, sum(o_totalprice) FROM dfs.`multilevel/json` group by dir0 order by dir0";
    QueryPlanFragments planFragments = getFragmentsHelper(query);
    assertNotNull(planFragments);
    assertTrue((planFragments.getFragmentsCount() > 1));
    for (PlanFragment planFragment : planFragments.getFragmentsList()) {
        assertTrue(planFragment.getLeafFragment());
    }
    int rowCount = getResultsHelper(planFragments);
    assertEquals(8, rowCount);
}
Also used : QueryPlanFragments(org.apache.drill.exec.proto.UserProtos.QueryPlanFragments) PlanFragment(org.apache.drill.exec.proto.BitControl.PlanFragment) DrillbitEndpoint(org.apache.drill.exec.proto.CoordinationProtos.DrillbitEndpoint) ClusterTest(org.apache.drill.test.ClusterTest) Test(org.junit.Test) PlannerTest(org.apache.drill.categories.PlannerTest) SlowTest(org.apache.drill.categories.SlowTest)

Example 2 with QueryPlanFragments

use of org.apache.drill.exec.proto.UserProtos.QueryPlanFragments in project drill by axbaretto.

the class DrillSeparatePlanningTest method testPlanningNegative.

@Test(timeout = 60_000)
public void testPlanningNegative() throws Exception {
    final String query = "SELECT dir0, sum(o_totalprice) FROM dfs.`multilevel/json` group by dir0 order by dir0";
    // LOGICAL is not supported
    final QueryPlanFragments planFragments = client.planQuery(QueryType.LOGICAL, query, false);
    assertNotNull(planFragments);
    assertNotNull(planFragments.getError());
    assertTrue(planFragments.getFragmentsCount() == 0);
}
Also used : QueryPlanFragments(org.apache.drill.exec.proto.UserProtos.QueryPlanFragments) ClusterTest(org.apache.drill.test.ClusterTest) Test(org.junit.Test) PlannerTest(org.apache.drill.categories.PlannerTest) SlowTest(org.apache.drill.categories.SlowTest)

Example 3 with QueryPlanFragments

use of org.apache.drill.exec.proto.UserProtos.QueryPlanFragments in project drill by apache.

the class DrillSeparatePlanningTest method testMultiMinorFragmentSimpleQuery.

@Test(timeout = 60_000)
public void testMultiMinorFragmentSimpleQuery() throws Exception {
    final String query = "SELECT o_orderkey FROM dfs.`multilevel/json`";
    QueryPlanFragments planFragments = getFragmentsHelper(query);
    assertNotNull(planFragments);
    assertTrue((planFragments.getFragmentsCount() > 1));
    for (PlanFragment planFragment : planFragments.getFragmentsList()) {
        assertTrue(planFragment.getLeafFragment());
    }
    int rowCount = getResultsHelper(planFragments);
    assertEquals(120, rowCount);
}
Also used : QueryPlanFragments(org.apache.drill.exec.proto.UserProtos.QueryPlanFragments) PlanFragment(org.apache.drill.exec.proto.BitControl.PlanFragment) DrillbitEndpoint(org.apache.drill.exec.proto.CoordinationProtos.DrillbitEndpoint) ClusterTest(org.apache.drill.test.ClusterTest) Test(org.junit.Test) PlannerTest(org.apache.drill.categories.PlannerTest) SlowTest(org.apache.drill.categories.SlowTest)

Example 4 with QueryPlanFragments

use of org.apache.drill.exec.proto.UserProtos.QueryPlanFragments in project drill by apache.

the class DrillSeparatePlanningTest method testPlanningNoSplit.

@Test(timeout = 60_000)
public void testPlanningNoSplit() throws Exception {
    final String query = "SELECT dir0, sum(o_totalprice) FROM dfs.`multilevel/json` group by dir0 order by dir0";
    client.alterSession("planner.slice_target", 1);
    try {
        final QueryPlanFragments planFragments = client.planQuery(query);
        assertNotNull(planFragments);
        assertTrue((planFragments.getFragmentsCount() > 1));
        PlanFragment rootFragment = planFragments.getFragments(0);
        assertFalse(rootFragment.getLeafFragment());
        QuerySummary summary = client.queryBuilder().plan(planFragments.getFragmentsList()).run();
        assertEquals(3, summary.recordCount());
    } finally {
        client.resetSession("planner.slice_target");
    }
}
Also used : QueryPlanFragments(org.apache.drill.exec.proto.UserProtos.QueryPlanFragments) QuerySummary(org.apache.drill.test.QueryBuilder.QuerySummary) PlanFragment(org.apache.drill.exec.proto.BitControl.PlanFragment) ClusterTest(org.apache.drill.test.ClusterTest) Test(org.junit.Test) PlannerTest(org.apache.drill.categories.PlannerTest) SlowTest(org.apache.drill.categories.SlowTest)

Example 5 with QueryPlanFragments

use of org.apache.drill.exec.proto.UserProtos.QueryPlanFragments in project drill by apache.

the class DrillSeparatePlanningTest method getFragmentsHelper.

private QueryPlanFragments getFragmentsHelper(final String query) throws InterruptedException, ExecutionException, RpcException {
    updateTestCluster(2, config);
    List<QueryDataBatch> results = client.runQuery(QueryType.SQL, "alter session set `planner.slice_target`=1");
    for (QueryDataBatch batch : results) {
        batch.release();
    }
    DrillRpcFuture<QueryPlanFragments> queryFragmentsFutures = client.planQuery(QueryType.SQL, query, true);
    final QueryPlanFragments planFragments = queryFragmentsFutures.get();
    for (PlanFragment fragment : planFragments.getFragmentsList()) {
        System.out.println(fragment.getFragmentJson());
    }
    return planFragments;
}
Also used : QueryDataBatch(org.apache.drill.exec.rpc.user.QueryDataBatch) QueryPlanFragments(org.apache.drill.exec.proto.UserProtos.QueryPlanFragments) PlanFragment(org.apache.drill.exec.proto.BitControl.PlanFragment)

Aggregations

QueryPlanFragments (org.apache.drill.exec.proto.UserProtos.QueryPlanFragments)15 PlannerTest (org.apache.drill.categories.PlannerTest)10 SlowTest (org.apache.drill.categories.SlowTest)10 ClusterTest (org.apache.drill.test.ClusterTest)10 Test (org.junit.Test)10 PlanFragment (org.apache.drill.exec.proto.BitControl.PlanFragment)7 DrillbitEndpoint (org.apache.drill.exec.proto.CoordinationProtos.DrillbitEndpoint)4 GetQueryPlanFragments (org.apache.drill.exec.proto.UserProtos.GetQueryPlanFragments)4 QuerySummary (org.apache.drill.test.QueryBuilder.QuerySummary)4 QueryContext (org.apache.drill.exec.ops.QueryContext)2 DrillPBError (org.apache.drill.exec.proto.UserBitShared.DrillPBError)2 QueryId (org.apache.drill.exec.proto.UserBitShared.QueryId)2 QueryDataBatch (org.apache.drill.exec.rpc.user.QueryDataBatch)1