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();
}
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;
}
Aggregations