in src/main/java/com/amazonaws/services/glue/catalog/HiveGlueCatalogSyncAgent.java [391:431]
public void onDropPartition(DropPartitionEvent partitionEvent) throws MetaException {
super.onDropPartition(partitionEvent);
if (!suppressAllDropEvents) {
if (partitionEvent.getStatus()) {
Table table = partitionEvent.getTable();
if (table.getTableType().equals(EXTERNAL_TABLE_TYPE) && table.getSd().getLocation().startsWith("s3")) {
String fqtn = getFqtn(table);
if (fqtn != null && !fqtn.equals("")) {
partitionEvent.getPartitionIterator().forEachRemaining(p -> {
String partitionSpec = getPartitionSpec(table, p);
if (p.getSd().getLocation().startsWith("s3")) {
String ddl = String.format("alter table %s drop if exists partition(%s);", fqtn,
partitionSpec);
if (!addToAthenaQueue(ddl)) {
LOG.error(String.format(
"Failed to add the DropPartition event to the processing queue for specification %s",
partitionSpec));
} else {
LOG.debug(String.format("Requested Drop of Partition with Specification (%s)",
partitionSpec));
}
} else {
LOG.debug(
String.format("Not dropping partition (%s) as it is not S3 based (location %s)",
partitionSpec, p.getSd().getLocation()));
}
});
}
} else {
LOG.debug(String.format("Ignoring Drop Partition Event for Table %s as it is not stored on S3",
table.getTableName()));
}
}
} else {
LOG.debug(String.format("Ignoring DropPartition event as %s set to True", SUPPRESS_ALL_DROP_EVENTS));
}
}