public GetPartitionsByNamesResponse handleRequest()

in hms-lambda-handler/src/main/java/com/amazonaws/athena/hms/handler/GetPartitionsByNamesHandler.java [41:66]


  public GetPartitionsByNamesResponse handleRequest(GetPartitionsByNamesRequest request, Context context)
  {
    HiveMetaStoreConf conf = getConf();
    try {
      context.getLogger().log("Connecting to embedded HMS client");
      HiveMetaStoreClient client = getClient();
      context.getLogger().log("Fetching partitions for DB: " + request.getDbName() + ", table: " + request.getTableName());
      List<Partition> partitionList =
          client.getPartitionsByNames(request.getDbName(), request.getTableName(), request.getNames());
      context.getLogger().log("Fetched partitions: " + (partitionList == null || partitionList.isEmpty() ? 0 : partitionList.size()));
      GetPartitionsByNamesResponse response = new GetPartitionsByNamesResponse();
      if (partitionList != null && !partitionList.isEmpty()) {
        TSerializer serializer = new TSerializer(getTProtocolFactory());
        List<String> jsonPartitionList = new ArrayList<>();
        for (Partition partition : partitionList) {
          jsonPartitionList.add(serializer.toString(partition, StandardCharsets.UTF_8.name()));
        }
        response.setPartitionDescs(jsonPartitionList);
      }
      return response;
    }
    catch (Exception e) {
      context.getLogger().log("Exception: " + e.getMessage());
      throw new RuntimeException(e);
    }
  }