use of org.apache.hadoop.hive.ql.exec.tez.TezTask in project hive by apache.
the class PostExecTezSummaryPrinter method run.
@Override
public void run(HookContext hookContext) throws Exception {
assert (hookContext.getHookType() == HookContext.HookType.POST_EXEC_HOOK);
HiveConf conf = hookContext.getConf();
if (!"tez".equals(HiveConf.getVar(conf, HiveConf.ConfVars.HIVE_EXECUTION_ENGINE))) {
return;
}
LOG.info("Executing post execution hook to print tez summary..");
SessionState ss = SessionState.get();
SessionState.LogHelper console = ss.getConsole();
QueryPlan plan = hookContext.getQueryPlan();
if (plan == null) {
return;
}
List<TezTask> rootTasks = Utilities.getTezTasks(plan.getRootTasks());
for (TezTask tezTask : rootTasks) {
LOG.info("Printing summary for tez task: " + tezTask.getName());
TezCounters counters = tezTask.getTezCounters();
if (counters != null) {
String hiveCountersGroup = HiveConf.getVar(conf, HiveConf.ConfVars.HIVECOUNTERGROUP);
for (CounterGroup group : counters) {
if (hiveCountersGroup.equals(group.getDisplayName())) {
console.printError(tezTask.getId() + " HIVE COUNTERS:");
for (TezCounter counter : group) {
console.printError(" " + counter.getDisplayName() + ": " + counter.getValue());
}
} else if (group.getName().equals(FileSystemCounter.class.getName())) {
console.printError(tezTask.getId() + " FILE SYSTEM COUNTERS:");
for (TezCounter counter : group) {
// local file system counters
if (counter.getName().contains("HDFS")) {
console.printError(" " + counter.getDisplayName() + ": " + counter.getValue());
}
}
} else if (group.getName().equals(LlapIOCounters.class.getName())) {
console.printError(tezTask.getId() + " LLAP IO COUNTERS:");
List<String> testSafeCounters = LlapIOCounters.testSafeCounterNames();
for (TezCounter counter : group) {
if (testSafeCounters.contains(counter.getDisplayName())) {
console.printError(" " + counter.getDisplayName() + ": " + counter.getValue());
}
}
}
}
}
}
}
use of org.apache.hadoop.hive.ql.exec.tez.TezTask in project hive by apache.
the class ATSHook method determineLlapId.
private ApplicationId determineLlapId(final HiveConf conf, QueryPlan plan) throws IOException {
// be added here, although this is only necessary to have extra debug information.
for (TezTask tezTask : Utilities.getTezTasks(plan.getRootTasks())) {
if (!tezTask.getWork().getLlapMode())
continue;
// In HS2, the client should have been cached already for the common case.
// Otherwise, this may actually introduce delay to compilation for the first query.
String hosts = HiveConf.getVar(conf, HiveConf.ConfVars.LLAP_DAEMON_SERVICE_HOSTS);
if (hosts != null && !hosts.isEmpty()) {
ApplicationId llapId = LlapRegistryService.getClient(conf).getApplicationId();
LOG.info("The query will use LLAP instance " + llapId + " (" + hosts + ")");
return llapId;
} else {
LOG.info("Cannot determine LLAP instance on client - service hosts are not set");
return null;
}
}
return null;
}
use of org.apache.hadoop.hive.ql.exec.tez.TezTask in project hive by apache.
the class CrossProductCheck method dispatch.
@Override
public Object dispatch(Node nd, Stack<Node> stack, Object... nodeOutputs) throws SemanticException {
@SuppressWarnings("unchecked") Task<? extends Serializable> currTask = (Task<? extends Serializable>) nd;
if (currTask instanceof MapRedTask) {
MapRedTask mrTsk = (MapRedTask) currTask;
MapredWork mrWrk = mrTsk.getWork();
checkMapJoins(mrTsk);
checkMRReducer(currTask.toString(), mrWrk);
} else if (currTask instanceof ConditionalTask) {
List<Task<? extends Serializable>> taskListInConditionalTask = ((ConditionalTask) currTask).getListTasks();
for (Task<? extends Serializable> tsk : taskListInConditionalTask) {
dispatch(tsk, stack, nodeOutputs);
}
} else if (currTask instanceof TezTask) {
TezTask tzTask = (TezTask) currTask;
TezWork tzWrk = tzTask.getWork();
checkMapJoins(tzWrk);
checkTezReducer(tzWrk);
}
return null;
}
use of org.apache.hadoop.hive.ql.exec.tez.TezTask in project hive by apache.
the class GenericUDTFGetSplits method createPlanFragment.
public PlanFragment createPlanFragment(String query, int num) throws HiveException {
HiveConf conf = new HiveConf(SessionState.get().getConf());
HiveConf.setVar(conf, ConfVars.HIVEFETCHTASKCONVERSION, "none");
HiveConf.setVar(conf, ConfVars.HIVEQUERYRESULTFILEFORMAT, PlanUtils.LLAP_OUTPUT_FORMAT_KEY);
String originalMode = HiveConf.getVar(conf, ConfVars.HIVE_EXECUTION_MODE);
HiveConf.setVar(conf, ConfVars.HIVE_EXECUTION_MODE, "llap");
HiveConf.setBoolVar(conf, ConfVars.HIVE_TEZ_GENERATE_CONSISTENT_SPLITS, true);
HiveConf.setBoolVar(conf, ConfVars.LLAP_CLIENT_CONSISTENT_SPLITS, true);
conf.setBoolean(TezSplitGrouper.TEZ_GROUPING_NODE_LOCAL_ONLY, true);
// Tez/LLAP requires RPC query plan
HiveConf.setBoolVar(conf, ConfVars.HIVE_RPC_QUERY_PLAN, true);
try {
jc = DagUtils.getInstance().createConfiguration(conf);
} catch (IOException e) {
throw new HiveException(e);
}
Driver driver = new Driver(conf);
try {
CommandProcessorResponse cpr = driver.compileAndRespond(query);
if (cpr.getResponseCode() != 0) {
throw new HiveException("Failed to compile query: " + cpr.getException());
}
QueryPlan plan = driver.getPlan();
List<Task<?>> roots = plan.getRootTasks();
Schema schema = convertSchema(plan.getResultSchema());
if (roots == null || roots.size() != 1 || !(roots.get(0) instanceof TezTask)) {
throw new HiveException("Was expecting a single TezTask.");
}
TezWork tezWork = ((TezTask) roots.get(0)).getWork();
if (tezWork.getAllWork().size() != 1) {
String tableName = "table_" + UUID.randomUUID().toString().replaceAll("[^A-Za-z0-9 ]", "");
String ctas = "create temporary table " + tableName + " as " + query;
LOG.info("Materializing the query for LLAPIF; CTAS: " + ctas);
try {
driver.resetQueryState();
HiveConf.setVar(conf, ConfVars.HIVE_EXECUTION_MODE, originalMode);
cpr = driver.run(ctas, false);
} catch (CommandNeedRetryException e) {
throw new HiveException(e);
}
if (cpr.getResponseCode() != 0) {
throw new HiveException("Failed to create temp table: " + cpr.getException());
}
HiveConf.setVar(conf, ConfVars.HIVE_EXECUTION_MODE, "llap");
query = "select * from " + tableName;
cpr = driver.compileAndRespond(query);
if (cpr.getResponseCode() != 0) {
throw new HiveException("Failed to create temp table: " + cpr.getException());
}
plan = driver.getPlan();
roots = plan.getRootTasks();
schema = convertSchema(plan.getResultSchema());
if (roots == null || roots.size() != 1 || !(roots.get(0) instanceof TezTask)) {
throw new HiveException("Was expecting a single TezTask.");
}
tezWork = ((TezTask) roots.get(0)).getWork();
}
return new PlanFragment(tezWork, schema, jc);
} finally {
driver.close();
driver.destroy();
}
}
use of org.apache.hadoop.hive.ql.exec.tez.TezTask in project hive by apache.
the class PostExecOrcRowGroupCountPrinter method run.
@Override
public void run(HookContext hookContext) throws Exception {
assert (hookContext.getHookType() == HookContext.HookType.POST_EXEC_HOOK);
HiveConf conf = hookContext.getConf();
if (!"tez".equals(HiveConf.getVar(conf, HiveConf.ConfVars.HIVE_EXECUTION_ENGINE))) {
return;
}
LOG.info("Executing post execution hook to print ORC row groups read counter..");
SessionState ss = SessionState.get();
SessionState.LogHelper console = ss.getConsole();
QueryPlan plan = hookContext.getQueryPlan();
if (plan == null) {
return;
}
List<TezTask> rootTasks = Utilities.getTezTasks(plan.getRootTasks());
for (TezTask tezTask : rootTasks) {
LOG.info("Printing ORC row group counter for tez task: " + tezTask.getName());
TezCounters counters = tezTask.getTezCounters();
if (counters != null) {
for (CounterGroup group : counters) {
if (group.getName().equals(LlapIOCounters.class.getName())) {
console.printError(tezTask.getId() + " LLAP IO COUNTERS:");
for (TezCounter counter : group) {
if (counter.getDisplayName().equals(LlapIOCounters.SELECTED_ROWGROUPS.name())) {
console.printError(" " + counter.getDisplayName() + ": " + counter.getValue());
}
}
}
}
}
}
}
Aggregations