From 606e7b966f1160ca0f30292e68b4ff2c662a8e4c Mon Sep 17 00:00:00 2001 From: Ovidiu <163712869+ovi-fabric@users.noreply.github.com> Date: Sat, 12 Sep 2026 18:27:15 +0300 Subject: [PATCH] feat(glue): support GetPartitionIndexes (#3416) Reading a table's partition indexes failed as an unsupported action, which makes a Glue table unmanageable as infrastructure: the Terraform AWS provider reads the indexes after creating a table and again on every refresh, so the create reports an error and every later plan fails on the same call. The table itself is fine - only the read of its indexes is missing - so the resource lands in state and then cannot be planned. Return an empty descriptor list. No index can exist while CreatePartitionIndex is unsupported, so empty is the accurate answer rather than a placeholder, and it is the answer a client reading a table's indexes needs. The table is resolved first so that a missing one is reported as missing rather than as a table that happens to have no indexes. --- .../floci/services/glue/GlueJsonHandler.java | 10 ++++ .../services/glue/GlueJsonHandlerTest.java | 46 +++++++++++++++++++ 2 files changed, 56 insertions(+) diff --git a/src/main/java/io/github/hectorvent/floci/services/glue/GlueJsonHandler.java b/src/main/java/io/github/hectorvent/floci/services/glue/GlueJsonHandler.java index e6a6bea468..f7e46efec3 100644 --- a/src/main/java/io/github/hectorvent/floci/services/glue/GlueJsonHandler.java +++ b/src/main/java/io/github/hectorvent/floci/services/glue/GlueJsonHandler.java @@ -84,6 +84,16 @@ public class GlueJsonHandler { Table table = glueService.getTable(dbName, tableName); yield Response.ok(Map.of("Table", table)).build(); } + case "GetPartitionIndexes" -> { + String dbName = request.get("DatabaseName").asText(); + String tableName = request.get("TableName").asText(); + // Resolve the table so a missing one is reported as such rather than as an empty + // index list. No index can exist until CreatePartitionIndex is supported, so the + // list is empty for every table that does resolve - which is the answer a client + // reading a table's indexes needs, rather than an unsupported-action failure. + glueService.getTable(dbName, tableName); + yield Response.ok(Map.of("PartitionIndexDescriptorList", List.of())).build(); + } case "GetTables" -> { String dbName = request.get("DatabaseName").asText(); yield Response.ok(Map.of("TableList", glueService.getTables(dbName))).build(); diff --git a/src/test/java/io/github/hectorvent/floci/services/glue/GlueJsonHandlerTest.java b/src/test/java/io/github/hectorvent/floci/services/glue/GlueJsonHandlerTest.java index b045323554..cdc0bf0d5e 100644 --- a/src/test/java/io/github/hectorvent/floci/services/glue/GlueJsonHandlerTest.java +++ b/src/test/java/io/github/hectorvent/floci/services/glue/GlueJsonHandlerTest.java @@ -17,6 +17,7 @@ import java.util.Map; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertThrows; import static org.junit.jupiter.api.Assertions.assertTrue; class GlueJsonHandlerTest { @@ -40,6 +41,51 @@ class GlueJsonHandlerTest { handler = new GlueJsonHandler(glueService, schemaRegistryService, mapper); } + private void createDatabaseAndTable(String dbName, String tableName) throws Exception { + ObjectNode createDb = mapper.createObjectNode(); + createDb.putObject("DatabaseInput").put("Name", dbName); + assertEquals(200, handler.handle("CreateDatabase", createDb, REGION).getStatus()); + + ObjectNode createTable = mapper.createObjectNode(); + createTable.put("DatabaseName", dbName); + createTable.putObject("TableInput").put("Name", tableName); + assertEquals(200, handler.handle("CreateTable", createTable, REGION).getStatus()); + } + + /** + * A client reading a table's partition indexes needs an answer, not an unsupported-action + * failure: the Terraform AWS provider reads them after creating a table and on every refresh, + * so without this a Glue table cannot be managed as a resource at all. + */ + @Test + void getPartitionIndexesReturnsAnEmptyListForAnExistingTable() throws Exception { + createDatabaseAndTable("indexes_db", "events"); + + ObjectNode request = mapper.createObjectNode(); + request.put("DatabaseName", "indexes_db"); + request.put("TableName", "events"); + + Response response = handler.handle("GetPartitionIndexes", request, REGION); + + assertEquals(200, response.getStatus()); + @SuppressWarnings("unchecked") + Map body = (Map) response.getEntity(); + assertTrue(body.containsKey("PartitionIndexDescriptorList")); + assertTrue(((java.util.List) body.get("PartitionIndexDescriptorList")).isEmpty()); + } + + /** A missing table is reported as missing, not as a table that happens to have no indexes. */ + @Test + void getPartitionIndexesOnAMissingTableFails() throws Exception { + createDatabaseAndTable("indexes_db2", "events"); + + ObjectNode request = mapper.createObjectNode(); + request.put("DatabaseName", "indexes_db2"); + request.put("TableName", "absent"); + + assertThrows(Exception.class, () -> handler.handle("GetPartitionIndexes", request, REGION)); + } + @Test void createCrawlerWithScheduleSucceeds() throws Exception { ObjectNode request = mapper.createObjectNode();