private void addPartitionData(DataOutputStream out, HiveConf conf, String columnPath, Table table,
      boolean isFormatted, boolean isOutputPadded) throws IOException {
    String partitionData = "";
    if (columnPath == null) {
      List<FieldSchema> partitionColumns = table.isPartitioned() ? table.getPartCols() : null;
      if (CollectionUtils.isNotEmpty(partitionColumns) &&
          conf.getBoolVar(ConfVars.HIVE_DISPLAY_PARTITION_COLUMNS_SEPARATELY)) {
        TextMetaDataTable metaDataTable = new TextMetaDataTable();
        boolean histogramEnabled = MetastoreConf.getBoolVar(conf, MetastoreConf.ConfVars.STATS_FETCH_KLL);
        partitionData += LINE_DELIM + "# Partition Information" + LINE_DELIM + "# ";
        metaDataTable.addRow(DescTableDesc.SCHEMA.split("#")[0].split(","));
        for (FieldSchema partitionColumn : partitionColumns) {
          metaDataTable.addRow(ShowUtils.extractColumnValues(
              partitionColumn, false, null, histogramEnabled));
        }
        partitionData += metaDataTable.renderTable(isOutputPadded);
      }
    } else {
      String statsState = table.getParameters().get(StatsSetupConst.COLUMN_STATS_ACCURATE);
      if (table.getParameters() != null && statsState != null) {
        StringBuilder stringBuilder = new StringBuilder();
        formatOutput(StatsSetupConst.COLUMN_STATS_ACCURATE,
            isFormatted ? StringEscapeUtils.escapeJava(statsState) : HiveStringUtils.escapeJava(statsState),
            stringBuilder, isOutputPadded);
        partitionData += stringBuilder.toString();
      }
    }
    out.write(partitionData.getBytes(StandardCharsets.UTF_8));
  }
Formats DESC TABLE results to text format.
ql/src/java/org/apache/hadoop/hive/ql/ddl/table/info/desc/formatter/TextDescTableFormatter.java