use of org.apache.hadoop.hive.ql.ddl.privilege.show.rolegrant.ShowRoleGrantDesc in project hive by apache.
the class HiveAuthorizationTaskFactoryImpl method createShowRoleGrantTask.
@Override
public Task<?> createShowRoleGrantTask(ASTNode ast, Path resultFile, Set<ReadEntity> inputs, Set<WriteEntity> outputs) {
ASTNode child = (ASTNode) ast.getChild(0);
PrincipalType principalType = PrincipalType.USER;
switch(child.getType()) {
case HiveParser.TOK_USER:
principalType = PrincipalType.USER;
break;
case HiveParser.TOK_GROUP:
principalType = PrincipalType.GROUP;
break;
case HiveParser.TOK_ROLE:
principalType = PrincipalType.ROLE;
break;
}
String principalName = BaseSemanticAnalyzer.unescapeIdentifier(child.getChild(0).getText());
ShowRoleGrantDesc showRoleGrantDesc = new ShowRoleGrantDesc(principalName, principalType, resultFile.toString());
return TaskFactory.get(new DDLWork(inputs, outputs, showRoleGrantDesc));
}
use of org.apache.hadoop.hive.ql.ddl.privilege.show.rolegrant.ShowRoleGrantDesc in project hive by apache.
the class TestHiveAuthorizationTaskFactory method testShowRoleGrantUser.
/**
* SHOW ROLE GRANT USER ...
*/
@Test
public void testShowRoleGrantUser() throws Exception {
DDLWork work = analyze("SHOW ROLE GRANT USER " + USER);
ShowRoleGrantDesc roleDesc = (ShowRoleGrantDesc) work.getDDLDesc();
Assert.assertNotNull("Role should not be null", roleDesc);
Assert.assertEquals(PrincipalType.USER, roleDesc.getPrincipalType());
Assert.assertEquals(USER, roleDesc.getName());
}
use of org.apache.hadoop.hive.ql.ddl.privilege.show.rolegrant.ShowRoleGrantDesc in project hive by apache.
the class TestHiveAuthorizationTaskFactory method testShowRoleGrantRole.
/**
* SHOW ROLE GRANT ROLE ...
*/
@Test
public void testShowRoleGrantRole() throws Exception {
DDLWork work = analyze("SHOW ROLE GRANT ROLE " + ROLE);
ShowRoleGrantDesc roleDesc = (ShowRoleGrantDesc) work.getDDLDesc();
Assert.assertNotNull("Role should not be null", roleDesc);
Assert.assertEquals(PrincipalType.ROLE, roleDesc.getPrincipalType());
Assert.assertEquals(ROLE, roleDesc.getName());
}
use of org.apache.hadoop.hive.ql.ddl.privilege.show.rolegrant.ShowRoleGrantDesc in project hive by apache.
the class TestHiveAuthorizationTaskFactory method testShowRoleGrantGroup.
/**
* SHOW ROLE GRANT GROUP ...
*/
@Test
public void testShowRoleGrantGroup() throws Exception {
DDLWork work = analyze("SHOW ROLE GRANT GROUP " + GROUP);
ShowRoleGrantDesc roleDesc = (ShowRoleGrantDesc) work.getDDLDesc();
Assert.assertNotNull("Role should not be null", roleDesc);
Assert.assertEquals(PrincipalType.GROUP, roleDesc.getPrincipalType());
Assert.assertEquals(GROUP, roleDesc.getName());
}
Aggregations