@Override
  public boolean run(CompactorContext context) throws IOException {
    HiveConf hiveConf = context.getConf();
    Table table = context.getTable();
    LOG.debug("Going to delete directories for aborted transactions for MM table " + table.getDbName() + "." + table
        .getTableName());
    QueryCompactor.Util.removeFilesForMmTable(hiveConf, context.getAcidDirectory());
    StorageDescriptor storageDescriptor = context.getSd();
    ValidWriteIdList writeIds = context.getValidWriteIdList();

    // Set up the session for driver.
    HiveConf driverConf = setUpDriverSession(hiveConf);

    // Note: we could skip creating the table and just add table type stuff directly to the
    //       "insert overwrite directory" command if there were no bucketing or list bucketing.
    String tmpTableName = getTempTableName(table);
    Path resultBaseDir = QueryCompactor.Util.getCompactionResultDir(
        storageDescriptor, writeIds, driverConf, true, true, false, null);

    List<String> createTableQueries = getCreateQueries(tmpTableName, table, storageDescriptor,
        resultBaseDir.toString());
    List<String> compactionQueries = getCompactionQueries(table, context.getPartition(), tmpTableName);
    List<String> dropQueries = getDropQueries(tmpTableName);
    runCompactionQueries(driverConf, tmpTableName, context.getCompactionInfo(), Lists.newArrayList(resultBaseDir), 
        createTableQueries, compactionQueries, dropQueries, table.getParameters());
    return true;
  }
Class responsible to run query based major compaction on insert only tables.
ql/src/java/org/apache/hadoop/hive/ql/txn/compactor/MmMajorQueryCompactor.java