class HiveEndpoint {

  public PartitionsAndStatistics getPartitions(Table table, String partitionPredicate, int maxPartitions)
    throws TException {
    try (CloseableMetaStoreClient client = metaStoreClientSupplier.get()) {
      List<Partition> partitions = null;
      if (Strings.isNullOrEmpty(partitionPredicate)) {
        partitions = client.listPartitions(table.getDbName(), table.getTableName(), (short) maxPartitions);
      } else {
        partitions = client.listPartitionsByFilter(table.getDbName(), table.getTableName(), partitionPredicate,
            (short) maxPartitions);
      }

      // Generate a list of partition names
      List<String> partitionNames = getPartitionNames(table.getPartitionKeys(), partitions);
      // Fetch the partition statistics
      List<String> columnNames = getColumnNames(table);

      Map<String, List<ColumnStatisticsObj>> statisticsByPartitionName = client
          .getPartitionColumnStatistics(table.getDbName(), table.getTableName(), partitionNames, columnNames);
      if (statisticsByPartitionName != null && !statisticsByPartitionName.isEmpty()) {
        log.debug("Retrieved column stats entries for {} partitions of table {}.{}", statisticsByPartitionName.size(),
            table.getDbName(), table.getTableName());
      } else {
        log.debug("No partition column stats retrieved for table {}.{}", table.getDbName(), table.getTableName());
      }

      return new PartitionsAndStatistics(table.getPartitionKeys(), partitions, statisticsByPartitionName);
    }
  }

  @Autowired public  HiveEndpoint(String name, HiveConf hiveConf, Supplier<CloseableMetaStoreClient> metaStoreClientSupplier);

}