@Test
  public void testAddPartitionMMInsertOverwrite() throws Exception{
    final String mmTable = "mmtblpartmsck";
    final String sourceTable = "nonacidpartmsck";
    runStatementOnDriver("drop table if exists " + acidTblPartMsck);
    runStatementOnDriver("drop table if exists " + mmTable);
    runStatementOnDriver("drop table if exists " + sourceTable);
    runStatementOnDriver("create table " + mmTable + "(a int, b int) partitioned by (p string) stored as orc"
        + " TBLPROPERTIES ('transactional'='true', 'transactional_properties'='insert_only')");
    runStatementOnDriver("create table " + sourceTable + "(a int, b int) partitioned by (p string) stored as orc"
        + " TBLPROPERTIES ('transactional'='false')");

    // Insert few rows
    runStatementOnDriver("insert into " + mmTable + " partition(p) values(1,1,'p1'),(2,2,'p1'),(3,3,'p1')");
    runStatementOnDriver("insert into " + mmTable + " partition(p) values(4,4,'p1')");
    runStatementOnDriver("insert into " + mmTable + " partition(p) values(1,2,'p2'),(2,3,'p2'),(3,4,'p2')");

    // Insert some to the source
    runStatementOnDriver("insert into " + sourceTable + " partition(p) values(10,10,'p1'),(20,20,'p1'),(30,30,'p1')");
    runStatementOnDriver("insert into " + sourceTable + " partition(p) values(40,40,'p1')");

    // Overwrite a partition
    runStatementOnDriver("insert overwrite table " + mmTable + " PARTITION(p='p1') " +
        " select a,b from " + sourceTable + " where " + sourceTable + ".p='p1'");

    List<String> r = runStatementOnDriver("select a, b from " + mmTable+ " order by a, b");
    int[][] expected = { { 1, 2 }, { 2, 3 }, { 3, 4 },{ 10, 10 }, { 20, 20 }, { 30, 30 }, {40, 40} };
    Assert.assertEquals(stringifyValues(expected), r);
    // Create target table
    runStatementOnDriver("create table " + acidTblPartMsck
        + " (a int, b int) partitioned by (p string) clustered by (a) into 2 buckets"
        + " stored as orc TBLPROPERTIES ('transactional'='true', 'transactional_properties'='insert_only')");

    // copy files on fs
    FileSystem fs = FileSystem.get(hiveConf);
    FileUtil.copy(fs, new Path(getWarehouseDir() + "/" + mmTable + "/p=p1"), fs,
        new Path(getWarehouseDir(), acidTblPartMsck), false, hiveConf);
    FileUtil.copy(fs, new Path(getWarehouseDir() + "/" + mmTable + "/p=p2"), fs,
        new Path(getWarehouseDir(), acidTblPartMsck), false, hiveConf);

    FileStatus[] fileStatuses = fs.listStatus(new Path(getWarehouseDir(), acidTblPartMsck + "/p=p1"));
    // Two delta and one insert overwrite base
    Assert.assertEquals(3, fileStatuses.length);
    // call msk repair
    runStatementOnDriver("msck repair table " + acidTblPartMsck);

    r = runStatementOnDriver("select a, b from " + acidTblPartMsck + " order by a, b");
    Assert.assertEquals(stringifyValues(expected), r);

    runStatementOnDriver("drop table if exists " + acidTblPartMsck);
    runStatementOnDriver("drop table if exists " + mmTable);
    runStatementOnDriver("drop table if exists " + sourceTable);
  }
Add one partition to an insert-only table that contains an insert overwrite base folder.
@throws Exception
ql/src/test/org/apache/hadoop/hive/ql/metadata/TestMSCKRepairOnAcid.java