private JSONObject getQueryPlan(HiveConf hiveConf, QueryPlan queryPlan) throws Exception {
   try {
     ExplainTask explain = new ExplainTask();
     explain.initialize(hiveConf, queryPlan, null);
     List<Task<?>> rootTasks = queryPlan.getRootTasks();
     return explain.getJSONPlan(
         null, null, rootTasks, queryPlan.getFetchTask(), true, false, false);
   } catch (Throwable e) {
     LOG.info("Failed to get queryplan", e);
     return new JSONObject();
   }
 }
Exemple #2
0
  protected ExecutionMode getExecutionMode(QueryPlan plan) {
    int numMRJobs = Utilities.getMRTasks(plan.getRootTasks()).size();
    int numSparkJobs = Utilities.getSparkTasks(plan.getRootTasks()).size();
    int numTezJobs = Utilities.getTezTasks(plan.getRootTasks()).size();

    ExecutionMode mode = ExecutionMode.MR;
    if (0 == (numMRJobs + numSparkJobs + numTezJobs)) {
      mode = ExecutionMode.NONE;
    } else if (numSparkJobs > 0) {
      return ExecutionMode.SPARK;
    } else if (numTezJobs > 0) {
      mode = ExecutionMode.TEZ;
      // Need to go in and check if any of the tasks is running in LLAP mode.
      for (TezTask tezTask : Utilities.getTezTasks(plan.getRootTasks())) {
        if (tezTask.getWork().getLlapMode()) {
          mode = ExecutionMode.LLAP;
          break;
        }
      }
    }

    return mode;
  }