Search in sources :

Example 1 with GetPartitionNamesPsRequest

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;
}
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 GetPartitionNamesPsRequest

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

Aggregations

GetPartitionNamesPsRequest (org.apache.hadoop.hive.metastore.api.GetPartitionNamesPsRequest)2 FileNotFoundException (java.io.FileNotFoundException)1 IOException (java.io.IOException)1 UnknownHostException (java.net.UnknownHostException)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 GetPartitionNamesPsResponse (org.apache.hadoop.hive.metastore.api.GetPartitionNamesPsResponse)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 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 TException (org.apache.thrift.TException)1