private String writeRolesGrantedInfo(List<HiveRoleGrant> roles, boolean testMode) {
    if (roles == null || roles.isEmpty()) {
      return "";
    }
    StringBuilder builder = new StringBuilder();
    //sort the list to get sorted (deterministic) output (for ease of testing)
    Collections.sort(roles);
    for (HiveRoleGrant role : roles) {
      ShowUtils.appendNonNull(builder, role.getRoleName(), true);
      ShowUtils.appendNonNull(builder, role.isGrantOption());
      ShowUtils.appendNonNull(builder, testMode ? -1 : role.getGrantTime() * 1000L);
      ShowUtils.appendNonNull(builder, role.getGrantor());
    }
    return builder.toString();
  }
Operation process of showing the role grants.
ql/src/java/org/apache/hadoop/hive/ql/ddl/privilege/show/rolegrant/ShowRoleGrantOperation.java