public static void invokeFailureHooks(DriverContext driverContext, PerfLogger perfLogger, HookContext hookContext,
      String errorMessage, Throwable exception) throws Exception {
    hookContext.setHookType(HookContext.HookType.ON_FAILURE_HOOK);
    hookContext.setErrorMessage(errorMessage);
    hookContext.setException(exception);
    // Get all the failure execution hooks and execute them.
    driverContext.getHookRunner().runFailureHooks(hookContext);
  }
For Query Based compaction to run the query to generate the compacted data.
ql/src/java/org/apache/hadoop/hive/ql/DriverUtils.java