@Test
  public void testSchemaEvolutionCompaction() throws Exception {
    String tblName = "schemaevolutioncompaction";
    runStatementOnDriver("drop table if exists " + tblName);
    runStatementOnDriver("CREATE TABLE " + tblName + "(a INT) " +
        " PARTITIONED BY(part string)" +
        " STORED AS ORC TBLPROPERTIES ('transactional'='true')");

    // First INSERT round.
    runStatementOnDriver("insert into " + tblName + " partition (part='aa') values (1)");

    // ALTER TABLE ... ADD COLUMNS
    runStatementOnDriver("ALTER TABLE " + tblName + " ADD COLUMNS(b int)");

    // Second INSERT round.
    runStatementOnDriver("insert into " + tblName + " partition (part='aa') values (2, 2000)");

    // Validate data
    List<String> res = runStatementOnDriver("SELECT * FROM " + tblName + " ORDER BY a");
    Assert.assertEquals(2, res.size());
    Assert.assertEquals("1\tNULL\taa", res.get(0));
    Assert.assertEquals("2\t2000\taa", res.get(1));

    // Compact
    CompactionRequest compactionRequest =
        new CompactionRequest("default", tblName, CompactionType.MAJOR);
    compactionRequest.setPartitionname("part=aa");
    txnHandler.compact(compactionRequest);
    runWorker(hiveConf);
    runCleaner(hiveConf);

    // Verify successful compaction
    List<ShowCompactResponseElement> compacts =
        txnHandler.showCompact(new ShowCompactRequest()).getCompacts();
    Assert.assertEquals(1, compacts.size());
    Assert.assertEquals(TxnStore.SUCCEEDED_RESPONSE, compacts.get(0).getState());

    // Validate data after compaction
    res = runStatementOnDriver("SELECT * FROM " + tblName + " ORDER BY a");
    Assert.assertEquals(2, res.size());
    Assert.assertEquals("1\tNULL\taa", res.get(0));
    Assert.assertEquals("2\t2000\taa", res.get(1));
  }
Create a table with schema evolution, and verify that no data is lost during (MR major)
compaction.

@throws Exception if a query fails
ql/src/test/org/apache/hadoop/hive/ql/TestTxnCommands2.java