private void explainOutput(BaseSemanticAnalyzer sem, QueryPlan plan) throws IOException {
    HiveConf conf = driverContext.getConf();

    boolean queryHistoryExplainPlanEnabled = conf.getBoolVar(
        HiveConf.ConfVars.HIVE_QUERY_HISTORY_ENABLED) && conf.getBoolVar(
        HiveConf.ConfVars.HIVE_QUERY_HISTORY_EXPLAIN_PLAN_ENABLED);

    if (conf.getBoolVar(ConfVars.HIVE_LOG_EXPLAIN_OUTPUT) ||
        conf.getBoolVar(ConfVars.HIVE_SERVER2_WEBUI_EXPLAIN_OUTPUT) || queryHistoryExplainPlanEnabled) {
      String explainOutput = ExplainTask.getExplainOutput(sem, plan, tree, queryState,
          context, conf);
      if (explainOutput != null) {
        if (conf.getBoolVar(ConfVars.HIVE_LOG_EXPLAIN_OUTPUT)) {
          if (conf.getBoolVar(ConfVars.HIVE_LOG_EXPLAIN_OUTPUT_TO_CONSOLE)) {
            CONSOLE.printInfo("EXPLAIN output for queryid " + driverContext.getQueryId() + " : " + explainOutput);
          } else {
            LOG.info("EXPLAIN output for queryid " + driverContext.getQueryId() + " : " + explainOutput);
          }
        }
        if (conf.isWebUiQueryInfoCacheEnabled() &&
            conf.getBoolVar(ConfVars.HIVE_SERVER2_WEBUI_EXPLAIN_OUTPUT)) {
          driverContext.getQueryDisplay().setExplainPlan(explainOutput);
        }
        if (queryHistoryExplainPlanEnabled){
          driverContext.setExplainPlan(explainOutput);
        }
      }
    }
  }
Get a Schema with fields represented with native Hive types.
ql/src/java/org/apache/hadoop/hive/ql/Compiler.java