Search in sources :

Example 6 with GrantDesc

use of org.apache.hadoop.hive.ql.plan.GrantDesc in project hive by apache.

the class HiveAuthorizationTaskFactoryImpl method createGrantTask.

@Override
public Task<? extends Serializable> createGrantTask(ASTNode ast, HashSet<ReadEntity> inputs, HashSet<WriteEntity> outputs) throws SemanticException {
    List<PrivilegeDesc> privilegeDesc = analyzePrivilegeListDef((ASTNode) ast.getChild(0));
    List<PrincipalDesc> principalDesc = AuthorizationParseUtils.analyzePrincipalListDef((ASTNode) ast.getChild(1));
    boolean grantOption = false;
    PrivilegeObjectDesc privilegeObj = null;
    if (ast.getChildCount() > 2) {
        for (int i = 2; i < ast.getChildCount(); i++) {
            ASTNode astChild = (ASTNode) ast.getChild(i);
            if (astChild.getType() == HiveParser.TOK_GRANT_WITH_OPTION) {
                grantOption = true;
            } else if (astChild.getType() == HiveParser.TOK_PRIV_OBJECT) {
                privilegeObj = analyzePrivilegeObject(astChild, outputs);
            }
        }
    }
    String userName = SessionState.getUserFromAuthenticator();
    GrantDesc grantDesc = new GrantDesc(privilegeObj, privilegeDesc, principalDesc, userName, PrincipalType.USER, grantOption);
    return TaskFactory.get(new DDLWork(inputs, outputs, grantDesc), conf);
}
Also used : PrincipalDesc(org.apache.hadoop.hive.ql.plan.PrincipalDesc) DDLWork(org.apache.hadoop.hive.ql.plan.DDLWork) PrivilegeObjectDesc(org.apache.hadoop.hive.ql.plan.PrivilegeObjectDesc) ASTNode(org.apache.hadoop.hive.ql.parse.ASTNode) GrantDesc(org.apache.hadoop.hive.ql.plan.GrantDesc) ShowGrantDesc(org.apache.hadoop.hive.ql.plan.ShowGrantDesc) PrivilegeDesc(org.apache.hadoop.hive.ql.plan.PrivilegeDesc)

Aggregations

GrantDesc (org.apache.hadoop.hive.ql.plan.GrantDesc)6 DDLWork (org.apache.hadoop.hive.ql.plan.DDLWork)5 PrincipalDesc (org.apache.hadoop.hive.ql.plan.PrincipalDesc)5 PrivilegeDesc (org.apache.hadoop.hive.ql.plan.PrivilegeDesc)5 ShowGrantDesc (org.apache.hadoop.hive.ql.plan.ShowGrantDesc)5 Test (org.junit.Test)3 Hive (org.apache.hadoop.hive.ql.metadata.Hive)1 ASTNode (org.apache.hadoop.hive.ql.parse.ASTNode)1 AlterTablePartMergeFilesDesc (org.apache.hadoop.hive.ql.parse.AlterTablePartMergeFilesDesc)1 PreInsertTableDesc (org.apache.hadoop.hive.ql.parse.PreInsertTableDesc)1 AbortTxnsDesc (org.apache.hadoop.hive.ql.plan.AbortTxnsDesc)1 AddPartitionDesc (org.apache.hadoop.hive.ql.plan.AddPartitionDesc)1 AlterDatabaseDesc (org.apache.hadoop.hive.ql.plan.AlterDatabaseDesc)1 AlterIndexDesc (org.apache.hadoop.hive.ql.plan.AlterIndexDesc)1 AlterTableAlterPartDesc (org.apache.hadoop.hive.ql.plan.AlterTableAlterPartDesc)1 AlterTableDesc (org.apache.hadoop.hive.ql.plan.AlterTableDesc)1 AlterTableExchangePartition (org.apache.hadoop.hive.ql.plan.AlterTableExchangePartition)1 AlterTableSimpleDesc (org.apache.hadoop.hive.ql.plan.AlterTableSimpleDesc)1 CacheMetadataDesc (org.apache.hadoop.hive.ql.plan.CacheMetadataDesc)1 CreateDatabaseDesc (org.apache.hadoop.hive.ql.plan.CreateDatabaseDesc)1