@Override
  public int execute() throws HiveException, IOException {
    HiveAuthorizer authorizer = PrivilegeUtils.getSessionAuthorizer(context.getConf());
    boolean testMode = context.getConf().getBoolVar(HiveConf.ConfVars.HIVE_IN_TEST);
    List<HiveRoleGrant> roles = authorizer.getRoleGrantInfoForPrincipal(
        AuthorizationUtils.getHivePrincipal(desc.getName(), desc.getPrincipalType()));
    ShowUtils.writeToFile(writeRolesGrantedInfo(roles, testMode), desc.getResFile(), context);

    return 0;
  }
Operation process of showing the role grants.
ql/src/java/org/apache/hadoop/hive/ql/ddl/privilege/show/rolegrant/ShowRoleGrantOperation.java