Search in sources :

Example 16 with MPartitionColumnPrivilege

use of org.apache.hadoop.hive.metastore.model.MPartitionColumnPrivilege in project hive by apache.

the class ObjectStore method getColumnPrivilege.

private List<PrivilegeGrantInfo> getColumnPrivilege(String catName, String dbName, String tableName, String columnName, String partitionName, String principalName, PrincipalType principalType) {
    tableName = normalizeIdentifier(tableName);
    dbName = normalizeIdentifier(dbName);
    columnName = normalizeIdentifier(columnName);
    catName = normalizeIdentifier(catName);
    if (partitionName == null) {
        List<MTableColumnPrivilege> userNameColumnPriv = this.listPrincipalMTableColumnGrants(principalName, principalType, catName, dbName, tableName, columnName);
        if (CollectionUtils.isNotEmpty(userNameColumnPriv)) {
            List<PrivilegeGrantInfo> grantInfos = new ArrayList<>(userNameColumnPriv.size());
            for (int i = 0; i < userNameColumnPriv.size(); i++) {
                MTableColumnPrivilege item = userNameColumnPriv.get(i);
                grantInfos.add(new PrivilegeGrantInfo(item.getPrivilege(), item.getCreateTime(), item.getGrantor(), getPrincipalTypeFromStr(item.getGrantorType()), item.getGrantOption()));
            }
            return grantInfos;
        }
    } else {
        List<MPartitionColumnPrivilege> userNameColumnPriv = this.listPrincipalMPartitionColumnGrants(principalName, principalType, catName, dbName, tableName, partitionName, columnName);
        if (CollectionUtils.isNotEmpty(userNameColumnPriv)) {
            List<PrivilegeGrantInfo> grantInfos = new ArrayList<>(userNameColumnPriv.size());
            for (int i = 0; i < userNameColumnPriv.size(); i++) {
                MPartitionColumnPrivilege item = userNameColumnPriv.get(i);
                grantInfos.add(new PrivilegeGrantInfo(item.getPrivilege(), item.getCreateTime(), item.getGrantor(), getPrincipalTypeFromStr(item.getGrantorType()), item.getGrantOption()));
            }
            return grantInfos;
        }
    }
    return Collections.emptyList();
}
Also used : PrivilegeGrantInfo(org.apache.hadoop.hive.metastore.api.PrivilegeGrantInfo) ArrayList(java.util.ArrayList) MPartitionColumnPrivilege(org.apache.hadoop.hive.metastore.model.MPartitionColumnPrivilege) MTableColumnPrivilege(org.apache.hadoop.hive.metastore.model.MTableColumnPrivilege) MConstraint(org.apache.hadoop.hive.metastore.model.MConstraint) SQLUniqueConstraint(org.apache.hadoop.hive.metastore.api.SQLUniqueConstraint) SQLCheckConstraint(org.apache.hadoop.hive.metastore.api.SQLCheckConstraint) SQLDefaultConstraint(org.apache.hadoop.hive.metastore.api.SQLDefaultConstraint) SQLNotNullConstraint(org.apache.hadoop.hive.metastore.api.SQLNotNullConstraint)

Example 17 with MPartitionColumnPrivilege

use of org.apache.hadoop.hive.metastore.model.MPartitionColumnPrivilege in project hive by apache.

the class ObjectStore method listPrincipalMPartitionColumnGrants.

private List<MPartitionColumnPrivilege> listPrincipalMPartitionColumnGrants(String principalName, PrincipalType principalType, String catName, String dbName, String tableName, String partitionName, String columnName, String authorizer) {
    boolean success = false;
    Query query = null;
    tableName = normalizeIdentifier(tableName);
    dbName = normalizeIdentifier(dbName);
    columnName = normalizeIdentifier(columnName);
    catName = normalizeIdentifier(catName);
    List<MPartitionColumnPrivilege> mSecurityColList = new ArrayList<>();
    try {
        LOG.debug("Executing listPrincipalPartitionColumnGrants");
        openTransaction();
        List<MPartitionColumnPrivilege> mPrivs;
        if (authorizer != null) {
            query = pm.newQuery(MPartitionColumnPrivilege.class, "principalName == t1 && principalType == t2 && partition.table.tableName == t3 " + "&& partition.table.database.name == t4 && partition.table.database.catalogName == t5" + " && partition.partitionName == t6 && columnName == t7 && authorizer == t8");
            query.declareParameters("java.lang.String t1, java.lang.String t2, java.lang.String t3, " + "java.lang.String t4, java.lang.String t5, java.lang.String t6, java.lang.String t7, " + "java.lang.String t8");
            mPrivs = (List<MPartitionColumnPrivilege>) query.executeWithArray(principalName, principalType.toString(), tableName, dbName, catName, partitionName, columnName, authorizer);
        } else {
            query = pm.newQuery(MPartitionColumnPrivilege.class, "principalName == t1 && principalType == t2 && partition.table.tableName == t3 " + "&& partition.table.database.name == t4 && partition.table.database.catalogName == t5" + " && partition.partitionName == t6 && columnName == t7");
            query.declareParameters("java.lang.String t1, java.lang.String t2, java.lang.String t3, " + "java.lang.String t4, java.lang.String t5, java.lang.String t6, java.lang.String t7");
            mPrivs = (List<MPartitionColumnPrivilege>) query.executeWithArray(principalName, principalType.toString(), tableName, dbName, catName, partitionName, columnName);
        }
        pm.retrieveAll(mPrivs);
        success = commitTransaction();
        mSecurityColList.addAll(mPrivs);
        LOG.debug("Done retrieving all objects for listPrincipalPartitionColumnGrants");
    } finally {
        rollbackAndCleanup(success, query);
    }
    return mSecurityColList;
}
Also used : ScheduledQuery(org.apache.hadoop.hive.metastore.api.ScheduledQuery) Query(javax.jdo.Query) MScheduledQuery(org.apache.hadoop.hive.metastore.model.MScheduledQuery) ArrayList(java.util.ArrayList) MPartitionColumnPrivilege(org.apache.hadoop.hive.metastore.model.MPartitionColumnPrivilege)

Aggregations

MPartitionColumnPrivilege (org.apache.hadoop.hive.metastore.model.MPartitionColumnPrivilege)17 ArrayList (java.util.ArrayList)12 MPartitionPrivilege (org.apache.hadoop.hive.metastore.model.MPartitionPrivilege)8 MTableColumnPrivilege (org.apache.hadoop.hive.metastore.model.MTableColumnPrivilege)8 MConstraint (org.apache.hadoop.hive.metastore.model.MConstraint)7 MTable (org.apache.hadoop.hive.metastore.model.MTable)7 MTablePrivilege (org.apache.hadoop.hive.metastore.model.MTablePrivilege)7 Query (javax.jdo.Query)6 HiveObjectPrivilege (org.apache.hadoop.hive.metastore.api.HiveObjectPrivilege)6 SQLCheckConstraint (org.apache.hadoop.hive.metastore.api.SQLCheckConstraint)6 SQLDefaultConstraint (org.apache.hadoop.hive.metastore.api.SQLDefaultConstraint)6 SQLNotNullConstraint (org.apache.hadoop.hive.metastore.api.SQLNotNullConstraint)6 SQLUniqueConstraint (org.apache.hadoop.hive.metastore.api.SQLUniqueConstraint)6 LinkedList (java.util.LinkedList)5 List (java.util.List)5 ValidReaderWriteIdList (org.apache.hadoop.hive.common.ValidReaderWriteIdList)5 ValidWriteIdList (org.apache.hadoop.hive.common.ValidWriteIdList)5 ReplicationMetricList (org.apache.hadoop.hive.metastore.api.ReplicationMetricList)5 ScheduledQuery (org.apache.hadoop.hive.metastore.api.ScheduledQuery)5 MScheduledQuery (org.apache.hadoop.hive.metastore.model.MScheduledQuery)5