Search in sources :

Example 41 with MetaException

use of org.apache.hadoop.hive.metastore.api.MetaException in project hive by apache.

the class HBaseStore method revokeRole.

@Override
public boolean revokeRole(Role role, String userName, PrincipalType principalType, boolean grantOption) throws MetaException, NoSuchObjectException {
    boolean commit = false;
    openTransaction();
    // then we need to remove the userName from the role altogether.
    try {
        if (grantOption) {
            // If this is a grant only change, we don't need to rebuild the user mappings.
            getHBase().dropPrincipalFromRole(role.getRoleName(), userName, principalType, grantOption);
        } else {
            Set<String> usersToRemap = findUsersToRemapRolesFor(role, userName, principalType);
            getHBase().dropPrincipalFromRole(role.getRoleName(), userName, principalType, grantOption);
            for (String user : usersToRemap) {
                getHBase().buildRoleMapForUser(user);
            }
        }
        commit = true;
        return true;
    } catch (IOException e) {
        LOG.error("Unable to revoke role " + role.getRoleName() + " from " + userName, e);
        throw new MetaException("Unable to revoke role " + e.getMessage());
    } finally {
        commitOrRoleBack(commit);
    }
}
Also used : IOException(java.io.IOException) MetaException(org.apache.hadoop.hive.metastore.api.MetaException)

Example 42 with MetaException

use of org.apache.hadoop.hive.metastore.api.MetaException in project hive by apache.

the class DDLTask method preInsertWork.

private int preInsertWork(Hive db, PreInsertTableDesc preInsertTableDesc) throws HiveException {
    try {
        HiveMetaHook hook = preInsertTableDesc.getTable().getStorageHandler().getMetaHook();
        if (hook == null || !(hook instanceof DefaultHiveMetaHook)) {
            return 0;
        }
        DefaultHiveMetaHook hiveMetaHook = (DefaultHiveMetaHook) hook;
        hiveMetaHook.preInsertTable(preInsertTableDesc.getTable().getTTable(), preInsertTableDesc.isOverwrite());
    } catch (MetaException e) {
        throw new HiveException(e);
    }
    return 0;
}
Also used : DefaultHiveMetaHook(org.apache.hadoop.hive.metastore.DefaultHiveMetaHook) HiveMetaHook(org.apache.hadoop.hive.metastore.HiveMetaHook) HiveException(org.apache.hadoop.hive.ql.metadata.HiveException) DefaultHiveMetaHook(org.apache.hadoop.hive.metastore.DefaultHiveMetaHook) MetaException(org.apache.hadoop.hive.metastore.api.MetaException)

Example 43 with MetaException

use of org.apache.hadoop.hive.metastore.api.MetaException in project hive by apache.

the class HBaseStorageHandler method commitDropTable.

@Override
public void commitDropTable(Table tbl, boolean deleteData) throws MetaException {
    try {
        String tableName = getHBaseTableName(tbl);
        boolean isExternal = MetaStoreUtils.isExternalTable(tbl);
        if (deleteData && !isExternal) {
            if (getHBaseAdmin().isTableEnabled(tableName)) {
                getHBaseAdmin().disableTable(tableName);
            }
            getHBaseAdmin().deleteTable(tableName);
        }
    } catch (IOException ie) {
        throw new MetaException(StringUtils.stringifyException(ie));
    }
}
Also used : IOException(java.io.IOException) MetaException(org.apache.hadoop.hive.metastore.api.MetaException)

Example 44 with MetaException

use of org.apache.hadoop.hive.metastore.api.MetaException in project hive by apache.

the class HCatClientHMSImpl method dropPartitions.

@Override
public void dropPartitions(String dbName, String tableName, Map<String, String> partitionSpec, boolean ifExists, boolean deleteData) throws HCatException {
    LOG.info("HCatClient dropPartitions(db=" + dbName + ",table=" + tableName + ", partitionSpec: [" + partitionSpec + "]).");
    try {
        dbName = checkDB(dbName);
        Table table = hmsClient.getTable(dbName, tableName);
        if (hiveConfig.getBoolVar(HiveConf.ConfVars.METASTORE_CLIENT_DROP_PARTITIONS_WITH_EXPRESSIONS)) {
            try {
                dropPartitionsUsingExpressions(table, partitionSpec, ifExists, deleteData);
            } catch (SemanticException parseFailure) {
                LOG.warn("Could not push down partition-specification to back-end, for dropPartitions(). Resorting to iteration.", parseFailure);
                dropPartitionsIteratively(dbName, tableName, partitionSpec, ifExists, deleteData);
            }
        } else {
            // Not using expressions.
            dropPartitionsIteratively(dbName, tableName, partitionSpec, ifExists, deleteData);
        }
    } catch (NoSuchObjectException e) {
        throw new ObjectNotFoundException("NoSuchObjectException while dropping partition. " + "Either db(" + dbName + ") or table(" + tableName + ") missing.", e);
    } catch (MetaException e) {
        throw new HCatException("MetaException while dropping partition.", e);
    } catch (TException e) {
        throw new ConnectionFailureException("TException while dropping partition.", e);
    }
}
Also used : TException(org.apache.thrift.TException) Table(org.apache.hadoop.hive.metastore.api.Table) HCatException(org.apache.hive.hcatalog.common.HCatException) NoSuchObjectException(org.apache.hadoop.hive.metastore.api.NoSuchObjectException) SemanticException(org.apache.hadoop.hive.ql.parse.SemanticException) MetaException(org.apache.hadoop.hive.metastore.api.MetaException)

Example 45 with MetaException

use of org.apache.hadoop.hive.metastore.api.MetaException in project hive by apache.

the class HCatClientHMSImpl method listPartitionsByFilter.

@Override
public List<HCatPartition> listPartitionsByFilter(String dbName, String tblName, String filter) throws HCatException {
    List<HCatPartition> hcatPtns = new ArrayList<HCatPartition>();
    try {
        HCatTable table = getTable(dbName, tblName);
        List<Partition> hivePtns = hmsClient.listPartitionsByFilter(table.getDbName(), table.getTableName(), filter, (short) -1);
        for (Partition ptn : hivePtns) {
            hcatPtns.add(new HCatPartition(table, ptn));
        }
    } catch (MetaException e) {
        throw new HCatException("MetaException while fetching partitions.", e);
    } catch (NoSuchObjectException e) {
        throw new ObjectNotFoundException("NoSuchObjectException while fetching partitions.", e);
    } catch (TException e) {
        throw new ConnectionFailureException("TException while fetching partitions.", e);
    }
    return hcatPtns;
}
Also used : TException(org.apache.thrift.TException) Partition(org.apache.hadoop.hive.metastore.api.Partition) ArrayList(java.util.ArrayList) HCatException(org.apache.hive.hcatalog.common.HCatException) NoSuchObjectException(org.apache.hadoop.hive.metastore.api.NoSuchObjectException) MetaException(org.apache.hadoop.hive.metastore.api.MetaException)

Aggregations

MetaException (org.apache.hadoop.hive.metastore.api.MetaException)318 IOException (java.io.IOException)123 ArrayList (java.util.ArrayList)95 NoSuchObjectException (org.apache.hadoop.hive.metastore.api.NoSuchObjectException)74 TException (org.apache.thrift.TException)67 Table (org.apache.hadoop.hive.metastore.api.Table)59 Partition (org.apache.hadoop.hive.metastore.api.Partition)57 SQLException (java.sql.SQLException)55 InvalidObjectException (org.apache.hadoop.hive.metastore.api.InvalidObjectException)53 Path (org.apache.hadoop.fs.Path)45 Connection (java.sql.Connection)36 InvalidOperationException (org.apache.hadoop.hive.metastore.api.InvalidOperationException)34 AlreadyExistsException (org.apache.hadoop.hive.metastore.api.AlreadyExistsException)32 Statement (java.sql.Statement)31 Test (org.junit.Test)30 List (java.util.List)25 Database (org.apache.hadoop.hive.metastore.api.Database)25 FieldSchema (org.apache.hadoop.hive.metastore.api.FieldSchema)25 ResultSet (java.sql.ResultSet)22 UnknownDBException (org.apache.hadoop.hive.metastore.api.UnknownDBException)22