mirror of
https://github.com/floci-io/floci.git
synced 2026-11-24 06:20:24 -05:00
fix(athena): align ListWorkGroups with AWS behavior (#1259)
This commit is contained in:
1 parent
94ad081241
commit
8c2d18b1d0
3 files changed
+68
-3
No files matched your search
@@ -68,7 +68,7 @@ public class AthenaJsonHandler {
|
||||
String name = request.has("WorkGroup") ? request.get("WorkGroup").asText() : "primary";
|
||||
yield Response.ok(Map.of("WorkGroup", athenaService.getWorkGroup(name))).build();
|
||||
}
|
||||
case "ListWorkGroups" -> Response.ok(Map.of("WorkGroups", athenaService.listWorkGroups())).build();
|
||||
case "ListWorkGroups" -> Response.ok(Map.of("WorkGroups", athenaService.listWorkGroups(region))).build();
|
||||
case "CreateWorkGroup" -> {
|
||||
CreateWorkGroupRequest createRequest = mapper.treeToValue(request, CreateWorkGroupRequest.class);
|
||||
athenaService.createWorkGroup(createRequest, region);
|
||||
|
||||
@@ -166,8 +166,14 @@ public class AthenaService {
|
||||
);
|
||||
}
|
||||
|
||||
public List<Map<String, Object>> listWorkGroups() {
|
||||
return List.of(Map.of("Name", DEFAULT_WORKGROUP, "State", "ENABLED"));
|
||||
public List<Map<String, Object>> listWorkGroups(String region) {
|
||||
List<Map<String, Object>> workGroups = new ArrayList<>();
|
||||
workGroups.add(primaryWorkGroupSummary());
|
||||
workGroups.addAll(workGroupStore.scan(k -> k.startsWith(region + ":")).stream()
|
||||
.sorted(Comparator.comparing(WorkGroup::getName))
|
||||
.map(this::toWorkGroupSummary)
|
||||
.toList());
|
||||
return workGroups;
|
||||
}
|
||||
|
||||
public List<Map<String, Object>> listDataCatalogs() {
|
||||
@@ -340,6 +346,30 @@ public class AthenaService {
|
||||
return engineVersion;
|
||||
}
|
||||
|
||||
private Map<String, Object> primaryWorkGroupSummary() {
|
||||
return Map.of(
|
||||
"Name", DEFAULT_WORKGROUP,
|
||||
"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
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
private Map<String, Object> toWorkGroupSummary(WorkGroup workGroup) {
|
||||
Map<String, Object> result = new LinkedHashMap<>();
|
||||
result.put("Name", workGroup.getName());
|
||||
result.put("State", workGroup.getState());
|
||||
return result;
|
||||
}
|
||||
|
||||
private List<WorkGroupTag> normalizeTags(List<WorkGroupTag> tags) {
|
||||
if (tags == null || tags.isEmpty()) {
|
||||
return List.of();
|
||||
|
||||
Reference in new issue
Block a user