use of org.apache.hadoop.hive.ql.ddl.privilege.show.grant.ShowGrantDesc in project hive by apache.
the class TestHiveAuthorizationTaskFactory method testShowGrantRoleOnTable.
/**
* SHOW GRANT ROLE ... ON TABLE ...
*/
@Test
public void testShowGrantRoleOnTable() throws Exception {
DDLWork work = analyze("SHOW GRANT ROLE " + ROLE + " ON TABLE " + TABLE);
ShowGrantDesc grantDesc = (ShowGrantDesc) work.getDDLDesc();
Assert.assertNotNull("Show grant should not be null", grantDesc);
Assert.assertEquals(PrincipalType.ROLE, grantDesc.getPrincipalDesc().getType());
Assert.assertEquals(ROLE, grantDesc.getPrincipalDesc().getName());
Assert.assertTrue("Expected table", grantDesc.getHiveObj().getTable());
Assert.assertEquals(TABLE_QNAME, grantDesc.getHiveObj().getObject());
Assert.assertTrue("Expected table", grantDesc.getHiveObj().getTable());
}
use of org.apache.hadoop.hive.ql.ddl.privilege.show.grant.ShowGrantDesc in project hive by apache.
the class TestHiveAuthorizationTaskFactory method testShowGrantUserOnTable.
/**
* SHOW GRANT USER ... ON TABLE ...
*/
@Test
public void testShowGrantUserOnTable() throws Exception {
DDLWork work = analyze("SHOW GRANT USER " + USER + " ON TABLE " + TABLE);
ShowGrantDesc grantDesc = (ShowGrantDesc) work.getDDLDesc();
Assert.assertNotNull("Show grant should not be null", grantDesc);
Assert.assertEquals(PrincipalType.USER, grantDesc.getPrincipalDesc().getType());
Assert.assertEquals(USER, grantDesc.getPrincipalDesc().getName());
Assert.assertTrue("Expected table", grantDesc.getHiveObj().getTable());
Assert.assertEquals(TABLE_QNAME, grantDesc.getHiveObj().getObject());
Assert.assertTrue("Expected table", grantDesc.getHiveObj().getTable());
}
use of org.apache.hadoop.hive.ql.ddl.privilege.show.grant.ShowGrantDesc in project hive by apache.
the class TestHiveAuthorizationTaskFactory method testShowGrantGroupOnTable.
/**
* SHOW GRANT GROUP ... ON TABLE ...
*/
@Test
public void testShowGrantGroupOnTable() throws Exception {
DDLWork work = analyze("SHOW GRANT GROUP " + GROUP + " ON TABLE " + TABLE);
ShowGrantDesc grantDesc = (ShowGrantDesc) work.getDDLDesc();
Assert.assertNotNull("Show grant should not be null", grantDesc);
Assert.assertEquals(PrincipalType.GROUP, grantDesc.getPrincipalDesc().getType());
Assert.assertEquals(GROUP, grantDesc.getPrincipalDesc().getName());
Assert.assertTrue("Expected table", grantDesc.getHiveObj().getTable());
Assert.assertEquals(TABLE_QNAME, grantDesc.getHiveObj().getObject());
Assert.assertTrue("Expected table", grantDesc.getHiveObj().getTable());
}
use of org.apache.hadoop.hive.ql.ddl.privilege.show.grant.ShowGrantDesc in project hive by apache.
the class HiveAuthorizationTaskFactoryImpl method createShowGrantTask.
@Override
public Task<?> createShowGrantTask(ASTNode ast, Path resultFile, Set<ReadEntity> inputs, Set<WriteEntity> outputs) throws SemanticException {
PrincipalDesc principalDesc = null;
PrivilegeObjectDesc privHiveObj = null;
ASTNode param = null;
if (ast.getChildCount() > 0) {
param = (ASTNode) ast.getChild(0);
principalDesc = AuthorizationParseUtils.getPrincipalDesc(param);
if (principalDesc != null) {
// shift one
param = (ASTNode) ast.getChild(1);
}
}
if (param != null) {
if (param.getType() == HiveParser.TOK_RESOURCE_ALL) {
privHiveObj = new PrivilegeObjectDesc(true, null, null, null);
} else if (param.getType() == HiveParser.TOK_PRIV_OBJECT_COL) {
privHiveObj = parsePrivObject(param);
}
}
ShowGrantDesc showGrant = new ShowGrantDesc(resultFile.toString(), principalDesc, privHiveObj);
return TaskFactory.get(new DDLWork(inputs, outputs, showGrant));
}
Aggregations