@Test public void testDropPartitionDeleteDataNoPurge() throws Exception { PartitionDropOptions partDropOptions = PartitionDropOptions.instance(); partDropOptions.deleteData(true); partDropOptions.purgeData(false); client.dropPartition(DB_NAME, TABLE_NAME, PARTITIONS[0].getValues(), partDropOptions); List<Partition> droppedPartitions = Lists.newArrayList(PARTITIONS[0]); List<Partition> remainingPartitions = Lists.newArrayList(PARTITIONS[1], PARTITIONS[2]); checkPartitionsAfterDelete(TABLE_NAME, droppedPartitions, remainingPartitions, true, false); }
@Test public void testDropPartitionDeleteDataAndPurge() throws Exception { PartitionDropOptions partDropOptions = PartitionDropOptions.instance(); partDropOptions.deleteData(true); partDropOptions.purgeData(true); client.dropPartition(DB_NAME, TABLE_NAME, PARTITIONS[0].getValues(), partDropOptions); List<Partition> droppedPartitions = Lists.newArrayList(PARTITIONS[0]); List<Partition> remainingPartitions = Lists.newArrayList(PARTITIONS[1], PARTITIONS[2]); checkPartitionsAfterDelete(TABLE_NAME, droppedPartitions, remainingPartitions, true, true); }
@Test public void testDropPartitionNotDeleteData() throws Exception { PartitionDropOptions partDropOptions = PartitionDropOptions.instance(); partDropOptions.deleteData(false); partDropOptions.purgeData(false); client.dropPartition(DB_NAME, TABLE_NAME, PARTITIONS[0].getValues(), partDropOptions); List<Partition> droppedPartitions = Lists.newArrayList(PARTITIONS[0]); List<Partition> remainingPartitions = Lists.newArrayList(PARTITIONS[1], PARTITIONS[2]); checkPartitionsAfterDelete(TABLE_NAME, droppedPartitions, remainingPartitions, false, false); }
@Test public void testDropPartitionNotDeleteDataPurge() throws Exception { PartitionDropOptions partDropOptions = PartitionDropOptions.instance(); partDropOptions.deleteData(false); partDropOptions.purgeData(true); client.dropPartition(DB_NAME, TABLE_NAME, PARTITIONS[0].getValues(), partDropOptions); List<Partition> droppedPartitions = Lists.newArrayList(PARTITIONS[0]); List<Partition> remainingPartitions = Lists.newArrayList(PARTITIONS[1], PARTITIONS[2]); checkPartitionsAfterDelete(TABLE_NAME, droppedPartitions, remainingPartitions, false, false); }
@Test public void testDropPartitionPurgeSetInTable() throws Exception { PartitionDropOptions partDropOptions = PartitionDropOptions.instance(); partDropOptions.deleteData(true); partDropOptions.purgeData(false); String tableName = "purge_test"; Map<String, String> tableParams = new HashMap<>(); tableParams.put("auto.purge", "true"); createTable(tableName, getYearPartCol(), tableParams); Partition partition1 = createPartition(tableName, null, Lists.newArrayList("2017"), getYearPartCol(), null); Partition partition2 = createPartition(tableName, null, Lists.newArrayList("2018"), getYearPartCol(), null); client.dropPartition(DB_NAME, tableName, partition1.getValues(), true); List<Partition> droppedPartitions = Lists.newArrayList(partition1); List<Partition> remainingPartitions = Lists.newArrayList(partition2); checkPartitionsAfterDelete(tableName, droppedPartitions, remainingPartitions, true, true); }
@Test public void testDropPartitionDeleteDataAndPurgeExternalTable() throws Exception { String tableName = "external_table"; Map<String, String> tableParams = new HashMap<>(); tableParams.put("EXTERNAL", "true"); createTable(tableName, getYearPartCol(), tableParams); String location = metaStore.getWarehouseRoot() + "/externalTable/year=2017"; Partition partition = createPartition(tableName, location, Lists.newArrayList("2017"), getYearPartCol(), null); PartitionDropOptions partDropOptions = PartitionDropOptions.instance(); partDropOptions.deleteData(true); partDropOptions.purgeData(true); client.dropPartition(DB_NAME, tableName, partition.getValues(), partDropOptions); List<Partition> partitionsAfterDrop = client.listPartitions(DB_NAME, tableName, MAX); Assert.assertTrue(partitionsAfterDrop.isEmpty()); Assert.assertTrue("The location '" + location + "' should exist.", metaStore.isPathExists(new Path(location))); }
.deleteData(true) .ifExists(true) .purgeData(dropTbl.getIfPurge())); for (Partition partition : droppedParts) { console.printInfo("Dropped the partition " + partition.getName());
PartitionDropOptions.instance() .deleteData(true) .purgeData(false) );
.deleteData(true) .ifExists(true) .purgeData(dropTbl.getIfPurge())); for (Partition partition : droppedParts) { console.printInfo("Dropped the partition " + partition.getName());
.ignoreProtection(dropTbl.getIgnoreProtection()) .ifExists(true) .purgeData(dropTbl.getIfPurge())); for (Partition partition : droppedParts) { console.printInfo("Dropped the partition " + partition.getName());