Examples of PrivilegeObjectDesc


Examples of org.apache.hadoop.hive.ql.plan.PrivilegeObjectDesc

    List<PrivilegeDesc> privilegeDesc = analyzePrivilegeListDef(
        (ASTNode) ast.getChild(0));
    List<PrincipalDesc> principalDesc = 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) {
View Full Code Here

Examples of org.apache.hadoop.hive.ql.plan.PrivilegeObjectDesc

  private void analyzeRevoke(ASTNode ast) throws SemanticException {
    List<PrivilegeDesc> privilegeDesc = analyzePrivilegeListDef(
        (ASTNode) ast.getChild(0));
    List<PrincipalDesc> principalDesc = analyzePrincipalListDef(
        (ASTNode) ast.getChild(1));
    PrivilegeObjectDesc hiveObj = null;
    if (ast.getChildCount() > 2) {
      ASTNode astChild = (ASTNode) ast.getChild(2);
      hiveObj = analyzePrivilegeObject(astChild, getOutputs());
    }
View Full Code Here

Examples of org.apache.hadoop.hive.ql.plan.PrivilegeObjectDesc

  }

  private PrivilegeObjectDesc analyzePrivilegeObject(ASTNode ast,
      HashSet<WriteEntity> outputs)
      throws SemanticException {
    PrivilegeObjectDesc subject = new PrivilegeObjectDesc();
    subject.setObject(unescapeIdentifier(ast.getChild(0).getText()));
    if (ast.getChildCount() > 1) {
      for (int i =0;i< ast.getChildCount();i++) {
        ASTNode astChild = (ASTNode) ast.getChild(i);
        if (astChild.getToken().getType() == HiveParser.TOK_PARTSPEC) {
          subject.setPartSpec(DDLSemanticAnalyzer.getPartSpec(astChild));
        } else {
          subject.setTable(ast.getChild(0) != null);
        }
      }
    }

    try {
      if (subject.getTable()) {
        Table tbl = db.getTable(subject.getObject());
        if (subject.getPartSpec() != null) {
          Partition part = db.getPartition(tbl, subject.getPartSpec(), false);
          outputs.add(new WriteEntity(part));
        } else {
          outputs.add(new WriteEntity(tbl));
        }
      }
View Full Code Here

Examples of org.apache.hadoop.hive.ql.plan.PrivilegeObjectDesc

    if(SessionState.get().isAuthorizationModeV2()){
      return showGrantsV2(showGrantDesc);
    }

    PrincipalDesc principalDesc = showGrantDesc.getPrincipalDesc();
    PrivilegeObjectDesc hiveObjectDesc = showGrantDesc.getHiveObj();
    String principalName = principalDesc == null ? null : principalDesc.getName();
    PrincipalType type = principalDesc == null ? null : principalDesc.getType();
    List<HiveObjectPrivilege> privs = new ArrayList<HiveObjectPrivilege>();
    try {
      if (hiveObjectDesc == null) {
        privs.addAll(db.showPrivilegeGrant(HiveObjectType.GLOBAL, principalName, type,
            null, null, null, null));
      } else if (hiveObjectDesc != null && hiveObjectDesc.getObject() == null) {
        privs.addAll(db.showPrivilegeGrant(null, principalName, type, null, null, null, null));
      } else {
        String obj = hiveObjectDesc.getObject();
        boolean notFound = true;
        String dbName = null;
        String tableName = null;
        Table tableObj = null;
        Database dbObj = null;

        if (hiveObjectDesc.getTable()) {
          String[] dbTab = obj.split("\\.");
          if (dbTab.length == 2) {
            dbName = dbTab[0];
            tableName = dbTab[1];
          } else {
            dbName = SessionState.get().getCurrentDatabase();
            tableName = obj;
          }
          dbObj = db.getDatabase(dbName);
          tableObj = db.getTable(dbName, tableName);
          notFound = (dbObj == null || tableObj == null);
        } else {
          dbName = hiveObjectDesc.getObject();
          dbObj = db.getDatabase(dbName);
          notFound = (dbObj == null);
        }
        if (notFound) {
          throw new HiveException(obj + " can not be found");
        }

        String partName = null;
        List<String> partValues = null;
        if (hiveObjectDesc.getPartSpec() != null) {
          partName = Warehouse
              .makePartName(hiveObjectDesc.getPartSpec(), false);
          partValues = Warehouse.getPartValuesFromPartName(partName);
        }

        if (!hiveObjectDesc.getTable()) {
          // show database level privileges
          privs.addAll(db.showPrivilegeGrant(HiveObjectType.DATABASE,
              principalName, type, dbName, null, null, null));
        } else {
          if (showGrantDesc.getColumns() != null) {
            // show column level privileges
            for (String columnName : showGrantDesc.getColumns()) {
              privs.addAll(db.showPrivilegeGrant(
                  HiveObjectType.COLUMN, principalName,
                  type, dbName, tableName, partValues,
                  columnName));
            }
          } else if (hiveObjectDesc.getPartSpec() != null) {
            // show partition level privileges
            privs.addAll(db.showPrivilegeGrant(
                HiveObjectType.PARTITION, principalName, type,
                dbName, tableName, partValues, null));
          } else {
View Full Code Here

Examples of org.apache.hadoop.hive.ql.plan.PrivilegeObjectDesc

    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) {
View Full Code Here

Examples of org.apache.hadoop.hive.ql.plan.PrivilegeObjectDesc

  @Override
  public Task<? extends Serializable> createRevokeTask(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));
    PrivilegeObjectDesc hiveObj = null;
    if (ast.getChildCount() > 2) {
      ASTNode astChild = (ASTNode) ast.getChild(2);
      hiveObj = analyzePrivilegeObject(astChild, outputs);
    }
    RevokeDesc revokeDesc = new RevokeDesc(privilegeDesc, principalDesc, hiveObj);
View Full Code Here

Examples of org.apache.hadoop.hive.ql.plan.PrivilegeObjectDesc

  @Override
  public Task<? extends Serializable> createShowGrantTask(ASTNode ast, Path resultFile, HashSet<ReadEntity> inputs,
      HashSet<WriteEntity> outputs) throws SemanticException {

    PrincipalDesc principalDesc = null;
    PrivilegeObjectDesc privHiveObj = null;
    List<String> cols = null;

    ASTNode param = null;
    if (ast.getChildCount() > 0) {
      param = (ASTNode) ast.getChild(0);
      principalDesc = AuthorizationParseUtils.getPrincipalDesc(param);
      if (principalDesc != null) {
        param = (ASTNode) ast.getChild(1)// shift one
      }
    }

    if (param != null) {
      if (param.getType() == HiveParser.TOK_RESOURCE_ALL) {
        privHiveObj = new PrivilegeObjectDesc();
      } else if (param.getType() == HiveParser.TOK_PRIV_OBJECT_COL) {
        privHiveObj = new PrivilegeObjectDesc();
        //set object name
        String text = param.getChild(0).getText();
        privHiveObj.setObject(BaseSemanticAnalyzer.unescapeIdentifier(text));
        //set object type
        ASTNode objTypeNode = (ASTNode) param.getChild(1);
        privHiveObj.setTable(objTypeNode.getToken().getType() == HiveParser.TOK_TABLE_TYPE);

        //set col and partition spec if specified
        for (int i = 2; i < param.getChildCount(); i++) {
          ASTNode partOrCol = (ASTNode) param.getChild(i);
          if (partOrCol.getType() == HiveParser.TOK_PARTSPEC) {
            privHiveObj.setPartSpec(DDLSemanticAnalyzer.getPartSpec(partOrCol));
          } else if (partOrCol.getType() == HiveParser.TOK_TABCOLNAME) {
            cols = BaseSemanticAnalyzer.getColumnNames(partOrCol);
          } else {
            throw new SemanticException("Invalid token type " + partOrCol.getType());
          }
View Full Code Here

Examples of org.apache.hadoop.hive.ql.plan.PrivilegeObjectDesc

  private PrivilegeObjectDesc analyzePrivilegeObject(ASTNode ast,
      HashSet<WriteEntity> outputs)
      throws SemanticException {

    PrivilegeObjectDesc subject = new PrivilegeObjectDesc();
    //set object identifier
    subject.setObject(BaseSemanticAnalyzer.unescapeIdentifier(ast.getChild(0).getText()));
    //set object type
    ASTNode objTypeNode =  (ASTNode) ast.getChild(1);
    subject.setTable(objTypeNode.getToken().getType() == HiveParser.TOK_TABLE_TYPE);
    if (ast.getChildCount() == 3) {
      //if partition spec node is present, set partition spec
      ASTNode partSpecNode = (ASTNode) ast.getChild(2);
      subject.setPartSpec(DDLSemanticAnalyzer.getPartSpec(partSpecNode));
    }

    if (subject.getTable()) {
      Table tbl = getTable(SessionState.get().getCurrentDatabase(), subject.getObject());
      if (subject.getPartSpec() != null) {
        Partition part = getPartition(tbl, subject.getPartSpec());
        outputs.add(new WriteEntity(part, WriteEntity.WriteType.DDL_NO_LOCK));
      } else {
        outputs.add(new WriteEntity(tbl, WriteEntity.WriteType.DDL_NO_LOCK));
      }
    }
View Full Code Here

Examples of org.apache.hadoop.hive.ql.plan.PrivilegeObjectDesc

    rootTasks.add(TaskFactory.get(new DDLWork(getInputs(), getOutputs(),
        grantRevokeRoleDDL), conf));
  }

  private void analyzeShowGrant(ASTNode ast) throws SemanticException {
    PrivilegeObjectDesc privHiveObj = null;

    ASTNode principal = (ASTNode) ast.getChild(0);
    PrincipalType type = PrincipalType.USER;
    switch (principal.getType()) {
    case HiveParser.TOK_USER:
      type = PrincipalType.USER;
      break;
    case HiveParser.TOK_GROUP:
      type = PrincipalType.GROUP;
      break;
    case HiveParser.TOK_ROLE:
      type = PrincipalType.ROLE;
      break;
    }
    String principalName = unescapeIdentifier(principal.getChild(0).getText());
    PrincipalDesc principalDesc = new PrincipalDesc(principalName, type);
    List<String> cols = null;
    if (ast.getChildCount() > 1) {
      ASTNode child = (ASTNode) ast.getChild(1);
      if (child.getToken().getType() == HiveParser.TOK_PRIV_OBJECT_COL) {
        privHiveObj = new PrivilegeObjectDesc();
        privHiveObj.setObject(unescapeIdentifier(child.getChild(0).getText()));
        if (child.getChildCount() > 1) {
          for (int i = 1; i < child.getChildCount(); i++) {
            ASTNode grandChild = (ASTNode) child.getChild(i);
            if (grandChild.getToken().getType() == HiveParser.TOK_PARTSPEC) {
              privHiveObj.setPartSpec(DDLSemanticAnalyzer.getPartSpec(grandChild));
            } else if (grandChild.getToken().getType() == HiveParser.TOK_TABCOLNAME) {
              cols = getColumnNames((ASTNode) grandChild);
            } else {
              privHiveObj.setTable(child.getChild(i) != null);
            }
          }
        }
      }
    }
View Full Code Here

Examples of org.apache.hadoop.hive.ql.plan.PrivilegeObjectDesc

    List<PrivilegeDesc> privilegeDesc = analyzePrivilegeListDef(
        (ASTNode) ast.getChild(0));
    List<PrincipalDesc> principalDesc = 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) {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.