static void runCompaction(HiveConf conf, String dbName, String tblName, CompactionType compactionType,
                            boolean isQueryBased, Map<String, String> properties, String... partNames) throws  Exception {
    HiveConf hiveConf = new HiveConf(conf);
    hiveConf.setBoolVar(HiveConf.ConfVars.COMPACTOR_CRUD_QUERY_BASED, isQueryBased);
    TxnStore txnHandler = TxnUtils.getTxnStore(hiveConf);
    Worker t = new Worker();
    t.setConf(hiveConf);
    t.init(new AtomicBoolean(true));
    CompactionRequest cr = new CompactionRequest(dbName, tblName, compactionType);
    if (properties != null) {
      cr.setProperties(properties);
    }
    if (partNames.length == 0) {
      txnHandler.compact(cr);
      t.run();
    } else {
      for (String partName : partNames) {
        cr.setPartitionname(partName);
        txnHandler.compact(cr);
        t.run();
      }
    }
  }
Trigger a compaction run.
@param conf hive configuration
@param dbName database name
@param tblName table name
@param compactionType major/minor
@param isQueryBased true, if query based compaction should be run
@param properties compaction request properties
@param partNames partition names
@throws Exception compaction cannot be started.
itests/hive-unit/src/test/java/org/apache/hadoop/hive/ql/txn/compactor/CompactorTestUtil.java