public GetPartitionsResponse handleRequest()

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


  public GetPartitionsResponse handleRequest(GetPartitionsRequest 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.listPartitions(request.getDbName(), request.getTableName(), request.getMaxSize());
      context.getLogger().log("Fetched partitions: " + (partitionList == null || partitionList.isEmpty() ? 0 : partitionList.size()));
      GetPartitionsResponse response = new GetPartitionsResponse();
      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.setPartitions(jsonPartitionList);
      }
      return response;
    }
    catch (Exception e) {
      context.getLogger().log("Exception: " + e.getMessage());
      throw new RuntimeException(e);
    }
  }