private void addStatsData(DataOutputStream out, HiveConf conf, String columnPath, List<FieldSchema> columns,
      boolean isFormatted, List<ColumnStatisticsObj> columnStats, boolean isOutputPadded) throws IOException {
    String statsData = "";
    
    TextMetaDataTable metaDataTable = new TextMetaDataTable();
    boolean needColStats = isFormatted && columnPath != null;
    boolean histogramEnabled = MetastoreConf.getBoolVar(conf, MetastoreConf.ConfVars.STATS_FETCH_KLL);
    if (needColStats) {
      metaDataTable.addRow(DescTableDesc.getColumnStatisticsHeaders(histogramEnabled).toArray(new String[0]));
    } else if (isFormatted && !SessionState.get().isHiveServerQuery()) {
      statsData += "# ";
      metaDataTable.addRow(DescTableDesc.SCHEMA.split("#")[0].split(","));
    }
    for (FieldSchema column : columns) {
      metaDataTable.addRow(ShowUtils.extractColumnValues(column, needColStats,
          getColumnStatisticsObject(column.getName(), column.getType(), columnStats), histogramEnabled));
    }
    if (needColStats) {
      metaDataTable.transpose();
    }
    statsData += metaDataTable.renderTable(isOutputPadded);
    out.write(statsData.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