Search in sources :

Example 31 with MetaException

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

the class HBaseStore method getDatabases.

@Override
public List<String> getDatabases(String pattern) throws MetaException {
    boolean commit = false;
    openTransaction();
    try {
        List<Database> dbs = getHBase().scanDatabases(pattern == null ? null : HiveStringUtils.normalizeIdentifier(likeToRegex(pattern)));
        List<String> dbNames = new ArrayList<String>(dbs.size());
        for (Database db : dbs) dbNames.add(db.getName());
        commit = true;
        return dbNames;
    } catch (IOException e) {
        LOG.error("Unable to get databases ", e);
        throw new MetaException("Unable to get databases, " + e.getMessage());
    } finally {
        commitOrRoleBack(commit);
    }
}
Also used : Database(org.apache.hadoop.hive.metastore.api.Database) ArrayList(java.util.ArrayList) IOException(java.io.IOException) MetaException(org.apache.hadoop.hive.metastore.api.MetaException)

Example 32 with MetaException

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

the class HBaseStore method createFunction.

@Override
public void createFunction(Function func) throws InvalidObjectException, MetaException {
    boolean commit = false;
    openTransaction();
    try {
        getHBase().putFunction(func);
        commit = true;
    } catch (IOException e) {
        LOG.error("Unable to create function", e);
        throw new MetaException("Unable to read from or write to hbase " + e.getMessage());
    } finally {
        commitOrRoleBack(commit);
    }
}
Also used : IOException(java.io.IOException) MetaException(org.apache.hadoop.hive.metastore.api.MetaException)

Example 33 with MetaException

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

the class HBaseStore method createDatabase.

@Override
public void createDatabase(Database db) throws InvalidObjectException, MetaException {
    boolean commit = false;
    openTransaction();
    try {
        Database dbCopy = db.deepCopy();
        dbCopy.setName(HiveStringUtils.normalizeIdentifier(dbCopy.getName()));
        // HiveMetaStore already checks for existence of the database, don't recheck
        getHBase().putDb(dbCopy);
        commit = true;
    } catch (IOException e) {
        LOG.error("Unable to create database ", e);
        throw new MetaException("Unable to read from or write to hbase " + e.getMessage());
    } finally {
        commitOrRoleBack(commit);
    }
}
Also used : Database(org.apache.hadoop.hive.metastore.api.Database) IOException(java.io.IOException) MetaException(org.apache.hadoop.hive.metastore.api.MetaException)

Example 34 with MetaException

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

the class HBaseStore method dropIndex.

@Override
public boolean dropIndex(String dbName, String origTableName, String indexName) throws MetaException {
    boolean commit = false;
    openTransaction();
    try {
        getHBase().deleteIndex(HiveStringUtils.normalizeIdentifier(dbName), HiveStringUtils.normalizeIdentifier(origTableName), HiveStringUtils.normalizeIdentifier(indexName));
        commit = true;
        return true;
    } catch (IOException e) {
        LOG.error("Unable to delete index" + e);
        throw new MetaException("Unable to drop index " + indexNameForErrorMsg(dbName, origTableName, indexName));
    } finally {
        commitOrRoleBack(commit);
    }
}
Also used : IOException(java.io.IOException) MetaException(org.apache.hadoop.hive.metastore.api.MetaException)

Example 35 with MetaException

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

the class HBaseStore method getForeignKeys.

@Override
public List<SQLForeignKey> getForeignKeys(String parent_db_name, String parent_tbl_name, String foreign_db_name, String foreign_tbl_name) throws MetaException {
    boolean commit = false;
    openTransaction();
    try {
        List<SQLForeignKey> fks = getHBase().getForeignKeys(foreign_db_name, foreign_tbl_name);
        if (fks == null || fks.size() == 0)
            return null;
        List<SQLForeignKey> result = new ArrayList<>(fks.size());
        for (SQLForeignKey fkcol : fks) {
            if ((parent_db_name == null || fkcol.getPktable_db().equals(parent_db_name)) && (parent_tbl_name == null || fkcol.getPktable_name().equals(parent_tbl_name))) {
                result.add(fkcol);
            }
        }
        commit = true;
        return result;
    } catch (IOException e) {
        LOG.error("Unable to get foreign key", e);
        throw new MetaException("Error reading db " + e.getMessage());
    } finally {
        commitOrRoleBack(commit);
    }
}
Also used : SQLForeignKey(org.apache.hadoop.hive.metastore.api.SQLForeignKey) ArrayList(java.util.ArrayList) IOException(java.io.IOException) 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