private void addExtendedInfo(Table table, Partition partition, MapBuilder builder) {
    if (partition != null) {
      builder.put("partitionInfo", partition.getTPartition());
    } else {
      builder.put("tableInfo", table.getTTable());
    }
    if (table.isNonNative() && table.getStorageHandler() != null &&
        table.getStorageHandler().supportsPartitionTransform()) {
      List<TransformSpec> specs = table.getStorageHandler().getPartitionTransformSpec(table);
      if (!specs.isEmpty()) {
        builder.put("partitionSpecInfo", specs.stream().map(s -> {
          Map<String, String> result = new LinkedHashMap<>();
          result.put("column_name", s.getColumnName());
          result.put("transform_type", s.getTransformType().name());
          if (s.getTransformParam().isPresent()) {
            result.put("transform_param", String.valueOf(s.getTransformParam().get()));
          }
          return result;
        }).collect(Collectors.toList()));
      }
    }
    if (PrimaryKeyInfo.isNotEmpty(table.getPrimaryKeyInfo())) {
      builder.put("primaryKeyInfo", table.getPrimaryKeyInfo());
    }
    if (ForeignKeyInfo.isNotEmpty(table.getForeignKeyInfo())) {
      builder.put("foreignKeyInfo", table.getForeignKeyInfo());
    }
    if (UniqueConstraint.isNotEmpty(table.getUniqueKeyInfo())) {
      builder.put("uniqueConstraintInfo", table.getUniqueKeyInfo());
    }
    if (NotNullConstraint.isNotEmpty(table.getNotNullConstraint())) {
      builder.put("notNullConstraintInfo", table.getNotNullConstraint());
    }
    if (DefaultConstraint.isNotEmpty(table.getDefaultConstraint())) {
      builder.put("defaultConstraintInfo", table.getDefaultConstraint());
    }
    if (CheckConstraint.isNotEmpty(table.getCheckConstraint())) {
      builder.put("checkConstraintInfo", table.getCheckConstraint());
    }
    if (table.getStorageHandlerInfo() != null) {
      builder.put("storageHandlerInfo", table.getStorageHandlerInfo().toString());
    }
  }
Formats DESC TABLE results to json format.
ql/src/java/org/apache/hadoop/hive/ql/ddl/table/info/desc/formatter/JsonDescTableFormatter.java