in hms-lambda-handler/src/main/java/com/amazonaws/athena/hms/handler/ListPartitionsHandler.java [77:110]
public ListPartitionsResponse handleRequest(ListPartitionsRequest request, Context context)
{
HiveMetaStoreConf conf = getConf();
try {
context.getLogger().log("Connecting to embedded HMS client");
HiveMetaStoreClient client = getClient();
ListPartitionsResponse response = new ListPartitionsResponse();
PartitionPaginator paginator = new PartitionPaginator(context, request, client);
PaginatedResponse<Partition> paginatedResponse = paginator.paginateByNames(request.getNextToken(), request.getMaxSize());
if (paginatedResponse != null) {
response.setNextToken(paginatedResponse.getNextToken());
List<Partition> partitions = paginatedResponse.getEntries();
if (partitions != null && !partitions.isEmpty()) {
TSerializer serializer = new TSerializer(getTProtocolFactory());
List<String> jsonPartitionList = new ArrayList<>();
for (Partition partition : partitions) {
jsonPartitionList.add(serializer.toString(partition, StandardCharsets.UTF_8.name()));
}
response.setPartitions(jsonPartitionList);
context.getLogger().log("Paginated response: entry size: " + jsonPartitionList.size()
+ ", nextToken: " + response.getNextToken());
}
}
return response;
}
catch (RuntimeException e) {
context.getLogger().log("Exception: " + e.getMessage());
throw e;
}
catch (Exception e) {
context.getLogger().log("Exception: " + e.getMessage());
throw new RuntimeException(e);
}
}