private String writeHiveRoleGrantInfo(List<HiveRoleGrant> roleGrants, boolean testMode) {
    if (roleGrants == null || roleGrants.isEmpty()) {
      return "";
    }
    StringBuilder builder = new StringBuilder();
    // sort the list to get sorted (deterministic) output (for ease of testing)
    Collections.sort(roleGrants);
    for (HiveRoleGrant roleGrant : roleGrants) {
      // schema: principal_name,principal_type,grant_option,grantor,grantor_type,grant_time
      ShowUtils.appendNonNull(builder, roleGrant.getPrincipalName(), true);
      ShowUtils.appendNonNull(builder, roleGrant.getPrincipalType());
      ShowUtils.appendNonNull(builder, roleGrant.isGrantOption());
      ShowUtils.appendNonNull(builder, roleGrant.getGrantor());
      ShowUtils.appendNonNull(builder, roleGrant.getGrantorType());
      ShowUtils.appendNonNull(builder, testMode ? -1 : roleGrant.getGrantTime() * 1000L);
    }
    return builder.toString();
  }
Operation process of showing the principals.
ql/src/java/org/apache/hadoop/hive/ql/ddl/privilege/show/principals/ShowPrincipalsOperation.java