@Test
  public void testCompactionOutputDirectoryNamesOnPartitionsAndOldDeltasDeleted() throws Exception {
    String p1 = "p=p1";
    String p2 = "p=p2";
    String oldDelta1 = "delta_0000001_0000001_0000";
    String oldDelta2 = "delta_0000002_0000002_0000";
    String oldDelta3 = "delta_0000003_0000003_0000";
    String oldDelta4 = "delta_0000004_0000004_0000";

    String expectedDelta1 = p1 + "/delta_0000001_0000002_v0000009";
    String expectedDelta2 = p2 + "/delta_0000003_0000004_v0000011";

    runStatementOnDriver("insert into " + Table.ACIDTBLPART + " partition(p='p1') (a,b) values(1,2)");
    runStatementOnDriver("insert into " + Table.ACIDTBLPART + " partition(p='p1') (a,b) values(3,4)");
    runStatementOnDriver("insert into " + Table.ACIDTBLPART + " partition(p='p2') (a,b) values(1,2)");
    runStatementOnDriver("insert into " + Table.ACIDTBLPART + " partition(p='p2') (a,b) values(3,4)");

    compactPartition(Table.ACIDTBLPART.name().toLowerCase(), CompactionType.MINOR, p1);
    compactPartition(Table.ACIDTBLPART.name().toLowerCase(), CompactionType.MINOR, p2);

    FileSystem fs = FileSystem.get(hiveConf);
    String tablePath = getWarehouseDir() + "/" + Table.ACIDTBLPART.name().toLowerCase() + "/";

    Assert.assertTrue(fs.exists(new Path(tablePath + expectedDelta1)));
    Assert.assertTrue(fs.exists(new Path(tablePath + expectedDelta2)));

    Assert.assertFalse(fs.exists(new Path(tablePath + oldDelta1)));
    Assert.assertFalse(fs.exists(new Path(tablePath + oldDelta2)));
    Assert.assertFalse(fs.exists(new Path(tablePath + oldDelta3)));
    Assert.assertFalse(fs.exists(new Path(tablePath + oldDelta4)));
  }
This tests that delete_delta_x_y dirs will be not produced during minor compaction if no input delete events.
See HIVE-20941.
@throws Exception
ql/src/test/org/apache/hadoop/hive/ql/TestTxnCommands2.java