@Override
  public void run(HookContext hookContext) throws Exception {
    assert(hookContext.getHookType() == HookType.PRE_EXEC_HOOK);
    QueryPlan plan = hookContext.getQueryPlan();
    if (plan == null) {
      return;
    }

    int numMrJobs = Utilities.getMRTasks(plan.getRootTasks()).size();
    List<TezTask> rootTasks = Utilities.getTezTasks(plan.getRootTasks());
    int numTezJobs = rootTasks.size();
    if (numMrJobs + numTezJobs <= 0) {
      return; // ignore client only queries
    }

    for (TezTask tezTask : rootTasks) {
      TezCounters tezCounters = new TezCounters();
      String groupName = CompileTimeCounters.class.getName();
      long totalFileSize = 0;
      long totalRawDataSize = 0;
      for (TezTask currTask : Utilities.getTezTasks(plan.getRootTasks())) {
        TezWork work = currTask.getWork();
        for (BaseWork w : work.getAllWork()) {
          for (Operator<?> op : w.getAllRootOperators()) {
            Set<TableScanOperator> tsOpSet = OperatorUtils.findOperators(op, TableScanOperator.class);
            // iterate all TS op from all work, and get the total file size (make appropriate DPP adjustment)
            for (TableScanOperator sourceTsOp : tsOpSet) {
              String vertexName = w.getName();
              String counterName = Utilities.getVertexCounterName(CompileTimeCounters.TOTAL_FILE_SIZE.name(), vertexName);
              totalFileSize += sourceTsOp.getStatistics().getTotalFileSize();
              totalRawDataSize += sourceTsOp.getStatistics().getDataSize();
              tezCounters.findCounter(groupName, counterName).increment(sourceTsOp.getStatistics().getTotalFileSize());
              counterName = Utilities.getVertexCounterName(CompileTimeCounters.RAW_DATA_SIZE.name(), vertexName);
              tezCounters.findCounter(groupName, counterName).increment(sourceTsOp.getStatistics().getDataSize());
            }
          }
        }
      }
      tezCounters.findCounter(groupName, CompileTimeCounters.TOTAL_FILE_SIZE.name()).increment(totalFileSize);
      tezCounters.findCounter(groupName, CompileTimeCounters.RAW_DATA_SIZE.name()).increment(totalRawDataSize);
      tezTask.setTezCounters(tezCounters);
    }
  }
Implementation of a pre execute hook that adds compile time tez counters to tez tasks.
ql/src/java/org/apache/hadoop/hive/ql/hooks/CompileTimeCounterPreHook.java