mirror of
https://github.com/floci-io/floci.git
synced 2026-11-24 06:20:24 -05:00
fix(athena): 🐛 align GetWorkGroup with AWS behavior (#1301)
GetWorkGroup previously returned a hardcoded default response for any workgroup name, ignoring workgroups created via CreateWorkGroup and never failing for non-existent ones. - Return stored Name, State, Description, CreationTime and Configuration for created workgroups, scoped by region - Throw InvalidRequestException (400) when the workgroup is not found, matching the AWS error shape and message - Keep the default view for the primary workgroup - Make DeleteWorkGroup actually remove the entry from the store so a deleted workgroup is no longer returned and its name can be reused - Document DeleteWorkGroup in the supported actions table Closes #1128
This commit is contained in:
1 parent
5078cac484
commit
ceb4d84431
4 files changed
+168
-16
No files matched your search
@@ -66,7 +66,7 @@ public class AthenaJsonHandler {
|
||||
}
|
||||
case "GetWorkGroup" -> {
|
||||
String name = request.has("WorkGroup") ? request.get("WorkGroup").asText() : "primary";
|
||||
yield Response.ok(Map.of("WorkGroup", athenaService.getWorkGroup(name))).build();
|
||||
yield Response.ok(Map.of("WorkGroup", athenaService.getWorkGroup(name, region))).build();
|
||||
}
|
||||
case "ListWorkGroups" -> Response.ok(Map.of("WorkGroups", athenaService.listWorkGroups(region))).build();
|
||||
case "CreateWorkGroup" -> {
|
||||
@@ -102,6 +102,7 @@ public class AthenaJsonHandler {
|
||||
if ("primary".equals(wg)) {
|
||||
throw new AwsException("InvalidRequestException", "The primary workgroup cannot be deleted.", 400);
|
||||
}
|
||||
athenaService.deleteWorkGroup(wg, region);
|
||||
yield Response.ok(Map.of()).build();
|
||||
}
|
||||
default -> throw new AwsException("InvalidAction", "Action " + action + " is not supported", 400);
|
||||
|
||||
@@ -149,21 +149,19 @@ public class AthenaService {
|
||||
return workGroup;
|
||||
}
|
||||
|
||||
public Map<String, Object> getWorkGroup(String name) {
|
||||
return Map.of(
|
||||
"Name", name == null || name.isBlank() ? DEFAULT_WORKGROUP : name,
|
||||
"State", "ENABLED",
|
||||
"Configuration", Map.of(
|
||||
"EngineVersion", Map.of(
|
||||
"SelectedEngineVersion", DEFAULT_ENGINE_VERSION,
|
||||
"EffectiveEngineVersion", DEFAULT_ENGINE_VERSION
|
||||
),
|
||||
"ResultConfiguration", Map.of("OutputLocation", "s3://" + DEFAULT_OUTPUT_BUCKET + "/results/"),
|
||||
"EnforceWorkGroupConfiguration", false,
|
||||
"PublishCloudWatchMetricsEnabled", false,
|
||||
"RequesterPaysEnabled", false
|
||||
)
|
||||
);
|
||||
public Map<String, Object> getWorkGroup(String name, String region) {
|
||||
String resolved = name == null || name.isBlank() ? DEFAULT_WORKGROUP : name;
|
||||
if (DEFAULT_WORKGROUP.equals(resolved)) {
|
||||
return primaryWorkGroupSummary();
|
||||
}
|
||||
WorkGroup workGroup = workGroupStore.get(workGroupKey(region, resolved))
|
||||
.orElseThrow(() -> new AwsException("InvalidRequestException",
|
||||
"WorkGroup " + resolved + " is not found.", 400));
|
||||
return toWorkGroupDetail(workGroup);
|
||||
}
|
||||
|
||||
public void deleteWorkGroup(String name, String region) {
|
||||
workGroupStore.delete(workGroupKey(region, name));
|
||||
}
|
||||
|
||||
public List<Map<String, Object>> listWorkGroups(String region) {
|
||||
@@ -363,6 +361,22 @@ public class AthenaService {
|
||||
);
|
||||
}
|
||||
|
||||
private Map<String, Object> toWorkGroupDetail(WorkGroup workGroup) {
|
||||
Map<String, Object> detail = new LinkedHashMap<>();
|
||||
detail.put("Name", workGroup.getName());
|
||||
detail.put("State", workGroup.getState());
|
||||
if (workGroup.getDescription() != null) {
|
||||
detail.put("Description", workGroup.getDescription());
|
||||
}
|
||||
if (workGroup.getCreationTime() != null) {
|
||||
detail.put("CreationTime", workGroup.getCreationTime());
|
||||
}
|
||||
if (workGroup.getConfiguration() != null) {
|
||||
detail.put("Configuration", workGroup.getConfiguration());
|
||||
}
|
||||
return detail;
|
||||
}
|
||||
|
||||
private Map<String, Object> toWorkGroupSummary(WorkGroup workGroup) {
|
||||
Map<String, Object> result = new LinkedHashMap<>();
|
||||
result.put("Name", workGroup.getName());
|
||||
|
||||
Reference in new issue
Block a user