use of org.apache.hadoop.hive.metastore.api.GetPartitionNamesPsResponse 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.GetPartitionNamesPsResponse in project hive by apache.
the class SessionHiveMetaStoreClient method listPartitionNamesRequestInternal.
@Override
protected GetPartitionNamesPsResponse listPartitionNamesRequestInternal(GetPartitionNamesPsRequest req) throws TException {
Map<Object, Object> queryCache = getQueryCache();
if (queryCache != null) {
// Retrieve or populate cache
CacheKey cacheKey = new CacheKey(KeyType.LIST_PARTITIONS_REQ, req);
GetPartitionNamesPsResponse v = (GetPartitionNamesPsResponse) queryCache.get(cacheKey);
if (v == null) {
v = super.listPartitionNamesRequestInternal(req);
queryCache.put(cacheKey, v);
} else {
LOG.debug("Query level HMS cache: method=listPartitionNamesRequestInternal, dbName={}, tblName={}, partValues={}", req.getDbName(), req.getTblName(), req.getPartValues());
}
return v;
}
return super.listPartitionNamesRequestInternal(req);
}
use of org.apache.hadoop.hive.metastore.api.GetPartitionNamesPsResponse in project hive by apache.
the class TestHiveMetaStoreClient method listPartitionNamesRequest.
public GetPartitionNamesPsResponse listPartitionNamesRequest(GetPartitionNamesPsRequest req) throws NoSuchObjectException, MetaException, TException {
assertNotNull(req.getId());
assertNotNull(req.getValidWriteIdList());
GetPartitionNamesPsResponse res = new GetPartitionNamesPsResponse();
return res;
}
use of org.apache.hadoop.hive.metastore.api.GetPartitionNamesPsResponse in project hive by apache.
the class SessionHiveMetaStoreClient method listPartitionNamesRequest.
@Override
public GetPartitionNamesPsResponse listPartitionNamesRequest(GetPartitionNamesPsRequest req) throws NoSuchObjectException, MetaException, TException {
String dbName = req.getDbName(), tblName = req.getTblName();
org.apache.hadoop.hive.metastore.api.Table table = getTempTable(dbName, tblName);
if (table == null) {
return super.listPartitionNamesRequest(req);
}
List<String> partVals = req.getPartValues();
short maxParts = req.getMaxParts();
TempTable tt = getPartitionedTempTable(table);
List<Partition> partitions = tt.getPartitionsByPartitionVals(partVals);
List<String> result = new ArrayList<>();
for (int i = 0; i < ((maxParts < 0 || maxParts > partitions.size()) ? partitions.size() : maxParts); i++) {
result.add(makePartName(table.getPartitionKeys(), partitions.get(i).getValues()));
}
Collections.sort(result);
GetPartitionNamesPsResponse response = new GetPartitionNamesPsResponse();
response.setNames(result);
return response;
}
Aggregations