@Override
  public PrincipalPrivilegeSet getConnectorPrivilegeSet (String catName, String connectorName,
      String userName, List<String> groupNames)  throws InvalidObjectException,
      MetaException {

    boolean commited = false;
    catName = normalizeIdentifier(catName);
    connectorName = normalizeIdentifier(connectorName);

    PrincipalPrivilegeSet ret = new PrincipalPrivilegeSet();
    try {
      openTransaction();

      // get user privileges
      if (userName != null) {
        Map<String, List<PrivilegeGrantInfo>> connectorUserPriv = new HashMap<>();
        connectorUserPriv.put(userName, getConnectorPrivilege(catName, connectorName, userName,
                PrincipalType.USER));
        ret.setUserPrivileges(connectorUserPriv);
      }

      // get group privileges
      if (CollectionUtils.isNotEmpty(groupNames)) {
        Map<String, List<PrivilegeGrantInfo>> dbGroupPriv = new HashMap<>();
        for (String groupName : groupNames) {
          dbGroupPriv.put(groupName, getConnectorPrivilege(catName, connectorName, groupName,
                  PrincipalType.GROUP));
        }
        ret.setGroupPrivileges(dbGroupPriv);
      }

      // get role privileges
      Set<String> roleNames = listAllRolesInHierarchy(userName, groupNames);
      if (CollectionUtils.isNotEmpty(roleNames)) {
        Map<String, List<PrivilegeGrantInfo>> dbRolePriv = new HashMap<>();
        for (String roleName : roleNames) {
          dbRolePriv.put(roleName, getConnectorPrivilege(catName, connectorName, roleName,
                  PrincipalType.ROLE));
        }
        ret.setRolePrivileges(dbRolePriv);
      }
      commited = commitTransaction();
    } finally {
      rollbackAndCleanup(commited, null);
    }
    return ret;


  }
Add role names of parentRoles and its parents to processedRoles
standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/ObjectStore.java