use of org.apache.hadoop.hive.metastore.api.GetPartitionNamesPsRequest in project hive by apache.
the class Hive method getPartitionNames.
public List<String> getPartitionNames(String dbName, String tblName, Map<String, String> partSpec, short max) throws HiveException {
List<String> names = null;
Table t = getTable(dbName, tblName);
List<String> pvals = MetaStoreUtils.getPvals(t.getPartCols(), partSpec);
try {
GetPartitionNamesPsRequest req = new GetPartitionNamesPsRequest();
req.setTblName(tblName);
req.setDbName(dbName);
req.setPartValues(pvals);
req.setMaxParts(max);
if (AcidUtils.isTransactionalTable(t)) {
ValidWriteIdList validWriteIdList = getValidWriteIdList(dbName, tblName);
req.setValidWriteIdList(validWriteIdList != null ? validWriteIdList.toString() : null);
req.setId(t.getTTable().getId());
}
GetPartitionNamesPsResponse res = getMSC().listPartitionNamesRequest(req);
names = res.getNames();
} catch (NoSuchObjectException nsoe) {
// listPartitionNames() throws NoSuchObjectException to indicate null partitions
return Lists.newArrayList();
} catch (Exception e) {
LOG.error("Failed getPartitionNames", e);
throw new HiveException(e);
}
return names;
}
use of org.apache.hadoop.hive.metastore.api.GetPartitionNamesPsRequest in project hive by apache.
the class TestSessionHiveMetastoreClientListPartitionsTempTable method checkPartitionNames.
private void checkPartitionNames(int numParts, List<String> partVals) throws Exception {
GetPartitionNamesPsRequest request = new GetPartitionNamesPsRequest();
request.setDbName(DB_NAME);
request.setTblName(TABLE_NAME);
request.setPartValues(partVals);
request.setMaxParts((short) -1);
List<String> partNames = getClient().listPartitionNamesRequest(request).getNames();
assertTrue(partNames.size() == numParts);
}
Aggregations