@Test
  public void testCompactionAbort() throws Exception {
    MetastoreConf.setBoolVar(hiveConf, MetastoreConf.ConfVars.CREATE_TABLES_AS_ACID, true);
    dropTables("T");
    //note: transaction names T1, T2, etc below, are logical, the actual txnid will be different
    runStatementOnDriver("create table T (a int, b int) stored as orc");
    runStatementOnDriver("insert into T values(0,2)");//makes delta_1_1 in T1
    runStatementOnDriver("insert into T values(1,4)");//makes delta_2_2 in T2

    //create failed compaction attempt so that compactor txn is aborted
    HiveConf.setBoolVar(hiveConf, HiveConf.ConfVars.HIVE_TEST_MODE_FAIL_COMPACTION, true);
    runStatementOnDriver("alter table T compact 'minor'");
    runWorker(hiveConf);

    TxnStore txnHandler = TxnUtils.getTxnStore(hiveConf);
    ShowCompactResponse resp = txnHandler.showCompact(new ShowCompactRequest());
    Assert.assertEquals("Unexpected number of compactions in history",
        1, resp.getCompactsSize());
    Assert.assertEquals("Unexpected 0th compaction state",
        TxnStore.FAILED_RESPONSE, resp.getCompacts().get(0).getState());
    GetOpenTxnsResponse openResp =  txnHandler.getOpenTxns();
    Assert.assertEquals(openResp.toString(), 1, openResp.getOpen_txnsSize());
    //check that the compactor txn is aborted
    Assert.assertTrue(openResp.toString(), BitSet.valueOf(openResp.getAbortedBits()).get(0));

    runCleaner(hiveConf);
    //we still have 1 aborted (compactor) txn
    Assert.assertTrue(openResp.toString(), BitSet.valueOf(openResp.getAbortedBits()).get(0));
    Assert.assertEquals(1, TestTxnDbUtil.countQueryAgent(hiveConf,
        "select count(*) from TXN_COMPONENTS"));
    //this returns 1 row since we only have 1 compaction executed
    int highestCompactWriteId = TestTxnDbUtil.countQueryAgent(hiveConf,
        "select CC_HIGHEST_WRITE_ID from COMPLETED_COMPACTIONS");
    /**
     * See {@link org.apache.hadoop.hive.metastore.txn.CompactionTxnHandler#updateCompactorState(CompactionInfo, long)}
     * for notes on why CC_HIGHEST_WRITE_ID=TC_WRITEID
     */
    Assert.assertEquals(1, TestTxnDbUtil.countQueryAgent(hiveConf,
        "select count(*) from TXN_COMPONENTS where TC_WRITEID=" + highestCompactWriteId));
    //now make a successful compactor run so that next Cleaner run actually cleans
    HiveConf.setBoolVar(hiveConf, HiveConf.ConfVars.HIVE_TEST_MODE_FAIL_COMPACTION, false);
    runStatementOnDriver("alter table T compact 'minor'");
    runWorker(hiveConf);

    resp = txnHandler.showCompact(new ShowCompactRequest());
    Assert.assertEquals("Unexpected number of compactions in history",
        2, resp.getCompactsSize());
    //check both combinations - don't know what order the db returns them in
    Assert.assertTrue("Unexpected compaction state",
        (TxnStore.FAILED_RESPONSE.equalsIgnoreCase(resp.getCompacts().get(0).getState())
            && TxnStore.CLEANING_RESPONSE.equalsIgnoreCase(resp.getCompacts().get(1).getState())) ||
            (TxnStore.CLEANING_RESPONSE.equalsIgnoreCase(resp.getCompacts().get(0).getState()) &&
                TxnStore.FAILED_RESPONSE.equalsIgnoreCase(resp.getCompacts().get(1).getState())));

    //delete metadata about aborted txn from txn_components and files (if any)
    runCleaner(hiveConf);
  }
Test that rows are routed to proper files based on bucket col/ROW__ID
Only the Vectorized Acid Reader checks if bucketId in ROW__ID inside the file
matches the file name and only for files in delete_delta
ql/src/test/org/apache/hadoop/hive/ql/TestTxnCommands3.java