public void transpose() {
      if (table.size() == 0) {
        return;
      }
      List<List<String>> newTable = new ArrayList<>();
      for (int i = 0; i < table.get(0).size(); i++) {
        newTable.add(new ArrayList<>());
      }
      for (List<String> sourceRow : table) {
        if (newTable.size() != sourceRow.size()) {
          throw new RuntimeException("invalid table size");
        }
        for (int i = 0; i < sourceRow.size(); i++) {
          newTable.get(i).add(sourceRow.get(i));
        }
      }
      table = newTable;
    }
Helps to format tables in SHOW ... command outputs.
ql/src/java/org/apache/hadoop/hive/ql/ddl/ShowUtils.java