private void addExtendedConstraintData(DataOutputStream out, Table table)
      throws IOException, UnsupportedEncodingException {
    if (table.getTableConstraintsInfo().isTableConstraintsInfoNotEmpty()) {
      out.write(("Constraints").getBytes(StandardCharsets.UTF_8));
      out.write(Utilities.tabCode);
      if (PrimaryKeyInfo.isNotEmpty(table.getPrimaryKeyInfo())) {
        out.write(table.getPrimaryKeyInfo().toString().getBytes(StandardCharsets.UTF_8));
        out.write(Utilities.newLineCode);
      }
      if (ForeignKeyInfo.isNotEmpty(table.getForeignKeyInfo())) {
        out.write(table.getForeignKeyInfo().toString().getBytes(StandardCharsets.UTF_8));
        out.write(Utilities.newLineCode);
      }
      if (UniqueConstraint.isNotEmpty(table.getUniqueKeyInfo())) {
        out.write(table.getUniqueKeyInfo().toString().getBytes(StandardCharsets.UTF_8));
        out.write(Utilities.newLineCode);
      }
      if (NotNullConstraint.isNotEmpty(table.getNotNullConstraint())) {
        out.write(table.getNotNullConstraint().toString().getBytes(StandardCharsets.UTF_8));
        out.write(Utilities.newLineCode);
      }
      if (DefaultConstraint.isNotEmpty(table.getDefaultConstraint())) {
        out.write(table.getDefaultConstraint().toString().getBytes(StandardCharsets.UTF_8));
        out.write(Utilities.newLineCode);
      }
      if (CheckConstraint.isNotEmpty(table.getCheckConstraint())) {
        out.write(table.getCheckConstraint().toString().getBytes(StandardCharsets.UTF_8));
        out.write(Utilities.newLineCode);
      }
    }
  }
Formats DESC TABLE results to text format.
ql/src/java/org/apache/hadoop/hive/ql/ddl/table/info/desc/formatter/TextDescTableFormatter.java