@Override
  public boolean run(CompactorContext context) throws IOException {
    LOG.info("Running query based minor compaction");
    HiveConf hiveConf = context.getConf();
    Table table = context.getTable();
    AcidUtils
        .setAcidOperationalProperties(hiveConf, true, AcidUtils.getAcidOperationalProperties(table.getParameters()));
    StorageDescriptor storageDescriptor = context.getSd();
    AcidDirectory dir = context.getAcidDirectory();
    ValidWriteIdList writeIds = context.getValidWriteIdList();
    
    // Set up the session for driver.
    HiveConf conf = setUpDriverSession(hiveConf);

    String tmpTableName =
        table.getDbName() + "_tmp_compactor_" + table.getTableName() + "_" + System.currentTimeMillis();

    Path resultDeltaDir = QueryCompactor.Util.getCompactionResultDir(storageDescriptor,
        writeIds, conf, false, false, false, dir);
    Path resultDeleteDeltaDir = QueryCompactor.Util.getCompactionResultDir(storageDescriptor,
        writeIds, conf, false, true, false, dir);

    List<String> createQueries = getCreateQueries(table, tmpTableName, dir, writeIds,
        resultDeltaDir, resultDeleteDeltaDir);
    List<String> compactionQueries = getCompactionQueries(tmpTableName, table, writeIds);
    List<String> dropQueries = getDropQueries(tmpTableName);

    runCompactionQueries(conf, tmpTableName, context.getCompactionInfo(), Lists.newArrayList(resultDeltaDir, resultDeleteDeltaDir), 
        createQueries, compactionQueries, dropQueries, table.getParameters());
    return true;
  }
Class responsible for handling query based minor compaction.
ql/src/java/org/apache/hadoop/hive/ql/txn/compactor/MinorQueryCompactor.java