Search in sources :

Example 1 with GetPartitionNamesPsResponse

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;
}
Also used : HiveMaterializedViewUtils.extractTable(org.apache.hadoop.hive.ql.optimizer.calcite.rules.views.HiveMaterializedViewUtils.extractTable) GetPartitionNamesPsRequest(org.apache.hadoop.hive.metastore.api.GetPartitionNamesPsRequest) ValidWriteIdList(org.apache.hadoop.hive.common.ValidWriteIdList) GetPartitionNamesPsResponse(org.apache.hadoop.hive.metastore.api.GetPartitionNamesPsResponse) NoSuchObjectException(org.apache.hadoop.hive.metastore.api.NoSuchObjectException) AlreadyExistsException(org.apache.hadoop.hive.metastore.api.AlreadyExistsException) LockException(org.apache.hadoop.hive.ql.lockmgr.LockException) InvalidOperationException(org.apache.hadoop.hive.metastore.api.InvalidOperationException) IOException(java.io.IOException) UnknownHostException(java.net.UnknownHostException) ExecutionException(java.util.concurrent.ExecutionException) NoSuchObjectException(org.apache.hadoop.hive.metastore.api.NoSuchObjectException) MetaException(org.apache.hadoop.hive.metastore.api.MetaException) HiveMetaException(org.apache.hadoop.hive.metastore.HiveMetaException) SemanticException(org.apache.hadoop.hive.ql.parse.SemanticException) TApplicationException(org.apache.thrift.TApplicationException) TException(org.apache.thrift.TException) SerDeException(org.apache.hadoop.hive.serde2.SerDeException) FileNotFoundException(java.io.FileNotFoundException) JDODataStoreException(javax.jdo.JDODataStoreException)

Example 2 with GetPartitionNamesPsResponse

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);
}
Also used : GetPartitionNamesPsResponse(org.apache.hadoop.hive.metastore.api.GetPartitionNamesPsResponse)

Example 3 with GetPartitionNamesPsResponse

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;
}
Also used : GetPartitionNamesPsResponse(org.apache.hadoop.hive.metastore.api.GetPartitionNamesPsResponse)

Example 4 with GetPartitionNamesPsResponse

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;
}
Also used : Partition(org.apache.hadoop.hive.metastore.api.Partition) ArrayList(java.util.ArrayList) GetPartitionNamesPsResponse(org.apache.hadoop.hive.metastore.api.GetPartitionNamesPsResponse)

Aggregations

GetPartitionNamesPsResponse (org.apache.hadoop.hive.metastore.api.GetPartitionNamesPsResponse)4 FileNotFoundException (java.io.FileNotFoundException)1 IOException (java.io.IOException)1 UnknownHostException (java.net.UnknownHostException)1 ArrayList (java.util.ArrayList)1 ExecutionException (java.util.concurrent.ExecutionException)1 JDODataStoreException (javax.jdo.JDODataStoreException)1 ValidWriteIdList (org.apache.hadoop.hive.common.ValidWriteIdList)1 HiveMetaException (org.apache.hadoop.hive.metastore.HiveMetaException)1 AlreadyExistsException (org.apache.hadoop.hive.metastore.api.AlreadyExistsException)1 GetPartitionNamesPsRequest (org.apache.hadoop.hive.metastore.api.GetPartitionNamesPsRequest)1 InvalidOperationException (org.apache.hadoop.hive.metastore.api.InvalidOperationException)1 MetaException (org.apache.hadoop.hive.metastore.api.MetaException)1 NoSuchObjectException (org.apache.hadoop.hive.metastore.api.NoSuchObjectException)1 Partition (org.apache.hadoop.hive.metastore.api.Partition)1 LockException (org.apache.hadoop.hive.ql.lockmgr.LockException)1 HiveMaterializedViewUtils.extractTable (org.apache.hadoop.hive.ql.optimizer.calcite.rules.views.HiveMaterializedViewUtils.extractTable)1 SemanticException (org.apache.hadoop.hive.ql.parse.SemanticException)1 SerDeException (org.apache.hadoop.hive.serde2.SerDeException)1 TApplicationException (org.apache.thrift.TApplicationException)1