fix: support Glue BatchDeleteTable (#1209)

* fix: support Glue BatchDeleteTable

* test: cover Glue BatchDeleteTable compatibility
This commit is contained in:
David Phillips authored and GitHub committed 2026-06-07 23:08:15 -05:00
1 parent 3894ffcf8a
commit 1ea22d0f60
5 files changed
+161 -8

No files matched your search

@@ -1,5 +1,6 @@
package io.github.hectorvent.floci.services.glue;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import io.github.hectorvent.floci.core.common.AwsException;
@@ -27,6 +28,8 @@ import java.util.Objects;
@ApplicationScoped
public class GlueJsonHandler {
private static final TypeReference<List<String>> STRING_LIST = new TypeReference<>() {};
private final GlueService glueService;
private final GlueSchemaRegistryService schemaRegistryService;
private final ObjectMapper mapper;
@@ -91,6 +94,11 @@ public class GlueJsonHandler {
glueService.deleteTable(dbName, tableName);
yield Response.ok().build();
}
case "BatchDeleteTable" -> {
String dbName = request.get("DatabaseName").asText();
List<String> tableNames = mapper.convertValue(request.get("TablesToDelete"), STRING_LIST);
yield Response.ok(Map.of("Errors", glueService.batchDeleteTables(dbName, tableNames))).build();
}
case "CreatePartition" -> {
String dbName = request.get("DatabaseName").asText();
String tableName = request.get("TableName").asText();
@@ -1,5 +1,6 @@
package io.github.hectorvent.floci.services.glue;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.core.type.TypeReference;
import io.github.hectorvent.floci.core.common.AwsException;
import io.github.hectorvent.floci.core.common.RegionResolver;
@@ -27,6 +28,7 @@ import java.util.LinkedHashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Optional;
import java.util.regex.Pattern;
import java.util.regex.PatternSyntaxException;
@@ -170,6 +172,23 @@ public class GlueService {
LOG.infov("Deleted Glue Table: {0}.{1}", databaseName, tableName);
}
public List<BatchDeleteTableError> batchDeleteTables(String databaseName, List<String> tableNames) {
getDatabase(databaseName);
List<BatchDeleteTableError> errors = new ArrayList<>();
for (String tableName : tableNames) {
String key = tableKey(databaseName, tableName);
Optional<Table> table = tableStore.get(key);
if (table.isEmpty()) {
errors.add(new BatchDeleteTableError(
tableName,
new ErrorDetail("EntityNotFoundException", "Table " + tableName + " not found")));
continue;
}
deleteTable(databaseName, tableName);
}
return errors;
}
public void createPartition(String databaseName, String tableName, Partition partition) {
Table table = getTable(databaseName, tableName);
String key = tableKey(databaseName, tableName) + ":" + String.join(",", partition.getValues());
@@ -338,6 +357,14 @@ public class GlueService {
public record UserDefinedFunctionPage(List<UserDefinedFunction> functions, String nextToken) {}
public record BatchDeleteTableError(
@JsonProperty("TableName") String tableName,
@JsonProperty("ErrorDetail") ErrorDetail errorDetail) {}
public record ErrorDetail(
@JsonProperty("ErrorCode") String errorCode,
@JsonProperty("ErrorMessage") String errorMessage) {}
private static Table copyTable(Table source) {
Table copy = new Table();
copy.setName(source.getName());