@Test
  public void testDropPartitionsWithPurge() throws Exception {
    String dbName = Warehouse.DEFAULT_DATABASE_NAME;
    String tableName = "table_for_testDropPartitionsWithPurge";

    try {

      Map<String, String> partitionSpec =  new ImmutableMap.Builder<String, String>()
                                                 .put("ds", "20141216")
                                                 .put("hr", "12")
                                                 .build();
      FileStatus[] trashContentsBeforeDrop = getTrashContents();
      int trashSizeBeforeDrop = trashContentsBeforeDrop.length;

      Table table = createPartitionedTable(dbName, tableName);
      hm.createPartition(table, partitionSpec);

      Partition partition = hm.getPartition(table, partitionSpec, false);
      assertNotNull("Newly created partition shouldn't be null!", partition);

      hm.dropPartition(dbName, tableName,
                       partition.getValues(),
                       PartitionDropOptions.instance()
                                           .deleteData(true)
                                           .purgeData(true)
                      );

      int trashSizeAfterDropPurge = getTrashContents().length;

      assertEquals("After dropPartitions(purge), trash should've remained unchanged!",
                 trashSizeBeforeDrop, trashSizeAfterDropPurge);

      // Repeat, and drop partition without purge.
      hm.createPartition(table, partitionSpec);

      partition = hm.getPartition(table, partitionSpec, false);
      assertNotNull("Newly created partition shouldn't be null!", partition);

      hm.dropPartition(dbName, tableName,
                       partition.getValues(),
                       PartitionDropOptions.instance()
                                           .deleteData(true)
                                           .purgeData(false)
                      );

      FileStatus[] trashContentsWithoutPurge = getTrashContents();
      int trashSizeWithoutPurge = trashContentsWithoutPurge.length;

      assertEquals("After dropPartitions(noPurge), data should've gone to trash, contents before drop: "
          + Arrays.asList(trashContentsBeforeDrop) + ", contents without purge: " + Arrays.asList(trashContentsWithoutPurge)
          + "!", trashSizeBeforeDrop, trashSizeWithoutPurge);
    }
    catch (Exception e) {
      fail("Unexpected exception: " + StringUtils.stringifyException(e));
    }
    finally {
      cleanUpTableQuietly(dbName, tableName);
    }
  }
Test for PURGE support for dropping partitions.
1. Drop partitions without PURGE, and check that the data isn't moved to Trash.
2. Drop partitions with PURGE, and check that the data is moved to Trash.
@throws Exception on failure.
ql/src/test/org/apache/hadoop/hive/ql/metadata/TestHive.java