mirror of
https://github.com/floci-io/floci.git
synced 2026-12-01 01:12:48 -05:00
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.
This commit is contained in:
1 parent
543bde7d5d
commit
606e7b966f
2 files changed
+56
No files matched your search
@@ -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<String, Object> body = (Map<String, Object>) 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();
|
||||
|
||||
Reference in new issue
Block a user