private static void populateInputJobInfo(
    Configuration conf, InputJobInfo inputJobInfo, String locationFilter) throws Exception {
    IMetaStoreClient client = null;
    HiveConf hiveConf = null;
    try {
      if (conf != null) {
        hiveConf = HCatUtil.getHiveConf(conf);
      } else {
        hiveConf = new HiveConf(HCatInputFormat.class);
      }
      client = HCatUtil.getHiveMetastoreClient(hiveConf);
      Table table = HCatUtil.getTable(client, inputJobInfo.getDatabaseName(),
        inputJobInfo.getTableName());

      List<PartInfo> partInfoList = new ArrayList<PartInfo>();

      inputJobInfo.setTableInfo(HCatTableInfo.valueOf(table.getTTable()));
      if (table.getPartitionKeys().size() != 0) {
        //Partitioned table
        List<Partition> parts = client.listPartitionsByFilter(inputJobInfo.getDatabaseName(),
          inputJobInfo.getTableName(),
          inputJobInfo.getFilter(),
          (short) -1);

        // Default to 100,000 partitions if hive.metastore.maxpartition is not defined
        int maxPart = hiveConf.getInt("hcat.metastore.maxpartitions", 100000);
        if (parts != null && parts.size() > maxPart) {
          throw new HCatException(ErrorType.ERROR_EXCEED_MAXPART, "total number of partitions is " + parts.size());
        }

        // populate partition info
        if (parts != null) {
          for (Partition ptn : parts) {
            HCatSchema schema = HCatUtil.extractSchema(
                    new org.apache.hadoop.hive.ql.metadata.Partition(table, ptn));
            PartInfo partInfo = extractPartInfo(schema, ptn.getSd(),
                    ptn.getParameters(), conf, inputJobInfo);
            partInfo.setPartitionValues(InternalUtil.createPtnKeyValueMap(table, ptn));
            partInfoList.add(partInfo);
          }
        }

      } else {
        //Non partitioned table
        HCatSchema schema = HCatUtil.extractSchema(table);
        PartInfo partInfo = extractPartInfo(schema, table.getTTable().getSd(),
          table.getParameters(), conf, inputJobInfo);
        partInfo.setPartitionValues(new HashMap<String, String>());
        partInfoList.add(partInfo);
      }
      inputJobInfo.setPartitions(partInfoList);

    } finally {
      HCatUtil.closeHiveClientQuietly(client);
    }

  }
Returns the given InputJobInfo after populating with data queried from the metadata service.
hcatalog/core/src/main/java/org/apache/hive/hcatalog/mapreduce/InitializeInput.java