private void collectPartitionSummary(Map<Long, MetadataTableSummary> summaries,  Set<Long> partedTabs,
      Set<Long> nonPartedTabs) throws MetaException {
    String queryText0 = "select \"TBL_ID\", count(1) from \"PARTITION_KEYS\" where \"TBL_ID\" in (";
    runBatched(batchSize, new ArrayList<>(summaries.keySet()), new Batchable<Long, Void>() {
      @Override
      public List<Void> run(List<Long> input) throws Exception {
        Pair<Query<?>, List<Object[]>> qResult = getResultFromInput(input, queryText0, " group by \"TBL_ID\"");
        try {
          List<Object[]> result = qResult.getRight();
          if (result != null) {
            for (Object[] fields : result) {
              Deadline.checkTimeout();
              Long tabId = Long.parseLong(String.valueOf(fields[0]));
              MetadataTableSummary summary = summaries.get(tabId);
              summary.setPartitionColumnCount(Integer.parseInt(fields[1].toString()));
              partedTabs.add(tabId);
            }
          }
          summaries.keySet().stream().filter(k -> !partedTabs.contains(k))
              .forEach(nonPartedTabs::add);
        } finally {
          qResult.getLeft().closeAll();
        }
        return Collections.emptyList();
      }
    });
    String queryText1 = "select \"TBL_ID\", count(1) from \"PARTITIONS\" where \"TBL_ID\" in (";
    runBatched(batchSize, new ArrayList<>(partedTabs), new Batchable<Long, Void>() {
      @Override
      public List<Void> run(List<Long> input) throws Exception {
        Pair<Query<?>, List<Object[]>> qResult = getResultFromInput(input, queryText1, " group by \"TBL_ID\"");
        try {
          List<Object[]> result = qResult.getRight();
          if (result != null) {
            for (Object[] fields : result) {
              Deadline.checkTimeout();
              Long tabId = Long.parseLong(String.valueOf(fields[0]));
              MetadataTableSummary summary = summaries.get(tabId);
              summary.setPartitionCount(Integer.parseInt(fields[1].toString()));
            }
          }
        } finally {
          qResult.getLeft().closeAll();
        }
        return Collections.emptyList();
      }
    });
  }
Using resultSet to read the HMS_SUMMARY table.
@param catalogFilter the optional catalog name filter
@param dbFilter the optional database name filter
@param tableFilter the optional table name filter
@return MetadataSummary
@throws MetaException
standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/tools/MetaToolObjectStore.java