Search in sources :

Example 36 with NoSuchObjectException

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

the class ObjectStore method getPartitionWithAuth.

@Override
public Partition getPartitionWithAuth(String dbName, String tblName, List<String> partVals, String user_name, List<String> group_names) throws NoSuchObjectException, MetaException, InvalidObjectException {
    boolean success = false;
    try {
        openTransaction();
        MPartition mpart = getMPartition(dbName, tblName, partVals);
        if (mpart == null) {
            commitTransaction();
            throw new NoSuchObjectException("partition values=" + partVals.toString());
        }
        Partition part = null;
        MTable mtbl = mpart.getTable();
        part = convertToPart(mpart);
        if ("TRUE".equalsIgnoreCase(mtbl.getParameters().get("PARTITION_LEVEL_PRIVILEGE"))) {
            String partName = Warehouse.makePartName(this.convertToFieldSchemas(mtbl.getPartitionKeys()), partVals);
            PrincipalPrivilegeSet partAuth = this.getPartitionPrivilegeSet(dbName, tblName, partName, user_name, group_names);
            part.setPrivileges(partAuth);
        }
        success = commitTransaction();
        return part;
    } finally {
        if (!success) {
            rollbackTransaction();
        }
    }
}
Also used : MPartition(org.apache.hadoop.hive.metastore.model.MPartition) Partition(org.apache.hadoop.hive.metastore.api.Partition) MTable(org.apache.hadoop.hive.metastore.model.MTable) PrincipalPrivilegeSet(org.apache.hadoop.hive.metastore.api.PrincipalPrivilegeSet) NoSuchObjectException(org.apache.hadoop.hive.metastore.api.NoSuchObjectException) MPartition(org.apache.hadoop.hive.metastore.model.MPartition)

Example 37 with NoSuchObjectException

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

the class ObjectStore method moveDescendents.

private void moveDescendents(MWMResourcePlan resourcePlan, String path, String newPoolPath) throws NoSuchObjectException {
    if (!poolParentExists(resourcePlan, newPoolPath)) {
        throw new NoSuchObjectException("Pool path is invalid, the parent does not exist");
    }
    boolean commited = false;
    Query query = null;
    openTransaction();
    try {
        query = pm.newQuery(MWMPool.class, "resourcePlan == rp && path.startsWith(poolPath)");
        query.declareParameters("MWMResourcePlan rp, java.lang.String poolPath");
        List<MWMPool> descPools = (List<MWMPool>) query.execute(resourcePlan, path + ".");
        pm.retrieveAll(descPools);
        for (MWMPool pool : descPools) {
            pool.setPath(newPoolPath + pool.getPath().substring(path.length()));
        }
        commited = commitTransaction();
    } finally {
        rollbackAndCleanup(commited, query);
    }
}
Also used : Query(javax.jdo.Query) MWMPool(org.apache.hadoop.hive.metastore.model.MWMPool) NoSuchObjectException(org.apache.hadoop.hive.metastore.api.NoSuchObjectException) LinkedList(java.util.LinkedList) MStringList(org.apache.hadoop.hive.metastore.model.MStringList) ArrayList(java.util.ArrayList) List(java.util.List)

Example 38 with NoSuchObjectException

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

the class ObjectStore method validateResourcePlan.

@Override
public WMValidateResourcePlanResponse validateResourcePlan(String name) throws NoSuchObjectException, InvalidObjectException, MetaException {
    name = normalizeIdentifier(name);
    Query query = null;
    try {
        query = pm.newQuery(MWMResourcePlan.class, "name == rpName");
        query.declareParameters("java.lang.String rpName");
        query.setUnique(true);
        MWMResourcePlan mResourcePlan = (MWMResourcePlan) query.execute(name);
        if (mResourcePlan == null) {
            throw new NoSuchObjectException("Cannot find resourcePlan: " + name);
        }
        // Validate resource plan.
        return getResourcePlanErrors(mResourcePlan);
    } finally {
        rollbackAndCleanup(true, query);
    }
}
Also used : Query(javax.jdo.Query) NoSuchObjectException(org.apache.hadoop.hive.metastore.api.NoSuchObjectException) MWMResourcePlan(org.apache.hadoop.hive.metastore.model.MWMResourcePlan)

Example 39 with NoSuchObjectException

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

the class ObjectStore method dropWMTrigger.

@Override
public void dropWMTrigger(String resourcePlanName, String triggerName) throws NoSuchObjectException, InvalidOperationException, MetaException {
    resourcePlanName = normalizeIdentifier(resourcePlanName);
    triggerName = normalizeIdentifier(triggerName);
    boolean commited = false;
    Query query = null;
    try {
        openTransaction();
        MWMResourcePlan resourcePlan = getMWMResourcePlan(resourcePlanName, true);
        query = pm.newQuery(MWMTrigger.class, "resourcePlan == rp && name == triggerName");
        query.declareParameters("MWMResourcePlan rp, java.lang.String triggerName");
        if (query.deletePersistentAll(resourcePlan, triggerName) != 1) {
            throw new NoSuchObjectException("Cannot delete trigger: " + triggerName);
        }
        commited = commitTransaction();
    } finally {
        rollbackAndCleanup(commited, query);
    }
}
Also used : Query(javax.jdo.Query) MWMTrigger(org.apache.hadoop.hive.metastore.model.MWMTrigger) NoSuchObjectException(org.apache.hadoop.hive.metastore.api.NoSuchObjectException) MWMResourcePlan(org.apache.hadoop.hive.metastore.model.MWMResourcePlan)

Example 40 with NoSuchObjectException

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

the class ObjectStore method deleteTableColumnStatistics.

@Override
public boolean deleteTableColumnStatistics(String dbName, String tableName, String colName) throws NoSuchObjectException, MetaException, InvalidObjectException, InvalidInputException {
    boolean ret = false;
    Query query = null;
    dbName = org.apache.commons.lang.StringUtils.defaultString(dbName, Warehouse.DEFAULT_DATABASE_NAME);
    if (tableName == null) {
        throw new InvalidInputException("Table name is null.");
    }
    try {
        openTransaction();
        MTable mTable = getMTable(dbName, tableName);
        MTableColumnStatistics mStatsObj;
        List<MTableColumnStatistics> mStatsObjColl;
        if (mTable == null) {
            throw new NoSuchObjectException("Table " + tableName + "  for which stats deletion is requested doesn't exist");
        }
        query = pm.newQuery(MTableColumnStatistics.class);
        String filter;
        String parameters;
        if (colName != null) {
            filter = "table.tableName == t1 && dbName == t2 && colName == t3";
            parameters = "java.lang.String t1, java.lang.String t2, java.lang.String t3";
        } else {
            filter = "table.tableName == t1 && dbName == t2";
            parameters = "java.lang.String t1, java.lang.String t2";
        }
        query.setFilter(filter);
        query.declareParameters(parameters);
        if (colName != null) {
            query.setUnique(true);
            mStatsObj = (MTableColumnStatistics) query.execute(normalizeIdentifier(tableName), normalizeIdentifier(dbName), normalizeIdentifier(colName));
            pm.retrieve(mStatsObj);
            if (mStatsObj != null) {
                pm.deletePersistent(mStatsObj);
            } else {
                throw new NoSuchObjectException("Column stats doesn't exist for db=" + dbName + " table=" + tableName + " col=" + colName);
            }
        } else {
            mStatsObjColl = (List<MTableColumnStatistics>) query.execute(normalizeIdentifier(tableName), normalizeIdentifier(dbName));
            pm.retrieveAll(mStatsObjColl);
            if (mStatsObjColl != null) {
                pm.deletePersistentAll(mStatsObjColl);
            } else {
                throw new NoSuchObjectException("Column stats doesn't exist for db=" + dbName + " table=" + tableName);
            }
        }
        ret = commitTransaction();
    } catch (NoSuchObjectException e) {
        rollbackTransaction();
        throw e;
    } finally {
        rollbackAndCleanup(ret, query);
    }
    return ret;
}
Also used : InvalidInputException(org.apache.hadoop.hive.metastore.api.InvalidInputException) MTable(org.apache.hadoop.hive.metastore.model.MTable) Query(javax.jdo.Query) MTableColumnStatistics(org.apache.hadoop.hive.metastore.model.MTableColumnStatistics) NoSuchObjectException(org.apache.hadoop.hive.metastore.api.NoSuchObjectException)

Aggregations

NoSuchObjectException (org.apache.hadoop.hive.metastore.api.NoSuchObjectException)144 MetaException (org.apache.hadoop.hive.metastore.api.MetaException)74 TException (org.apache.thrift.TException)55 InvalidObjectException (org.apache.hadoop.hive.metastore.api.InvalidObjectException)47 Table (org.apache.hadoop.hive.metastore.api.Table)45 Partition (org.apache.hadoop.hive.metastore.api.Partition)44 ArrayList (java.util.ArrayList)42 IOException (java.io.IOException)39 InvalidOperationException (org.apache.hadoop.hive.metastore.api.InvalidOperationException)36 AlreadyExistsException (org.apache.hadoop.hive.metastore.api.AlreadyExistsException)30 Test (org.junit.Test)24 Database (org.apache.hadoop.hive.metastore.api.Database)22 FieldSchema (org.apache.hadoop.hive.metastore.api.FieldSchema)21 InvalidInputException (org.apache.hadoop.hive.metastore.api.InvalidInputException)20 UnknownDBException (org.apache.hadoop.hive.metastore.api.UnknownDBException)20 Path (org.apache.hadoop.fs.Path)19 Query (javax.jdo.Query)17 SQLException (java.sql.SQLException)16 ConnectorException (com.netflix.metacat.common.server.connectors.exception.ConnectorException)13 InvalidMetaException (com.netflix.metacat.common.server.connectors.exception.InvalidMetaException)13