private void deleteSchemaInternal(String schemaName) {
Schema schema = _pinotHelixResourceManager.getSchema(schemaName);
if (schema == null) {
throw new ControllerApplicationException(LOGGER, String.format("Schema %s not found", schemaName),
Response.Status.NOT_FOUND);
}
List<String> tableNames = _pinotHelixResourceManager.getAllRealtimeTables();
for (String tableName : tableNames) {
TableConfig config = _pinotHelixResourceManager.getRealtimeTableConfig(tableName);
String tableSchema = config.getValidationConfig().getSchemaName();
if (schemaName.equals(tableSchema)) {
throw new ControllerApplicationException(LOGGER,
String.format("Cannot delete schema %s, as it is associated with table %s", schemaName, tableName),
Response.Status.CONFLICT);
}
}
LOGGER.info("Trying to delete schema {}", schemaName);
if (_pinotHelixResourceManager.deleteSchema(schema)) {
LOGGER.info("Success: Deleted schema {}", schemaName);
} else {
throw new ControllerApplicationException(LOGGER, String.format("Failed to delete schema %s", schemaName),
Response.Status.INTERNAL_SERVER_ERROR);
}
}
}