private Object toJson(RelDataType node) {
    if (Bug.CALCITE_6832_FIXED) {
      throw new IllegalStateException("Method is redundant after CALCITE-6832");
    }
    final Map<String, Object> map = jsonBuilder.map();
    if (node.isStruct()) {
      final List<Object> list = jsonBuilder.list();
      for (RelDataTypeField field : node.getFieldList()) {
        Map<String, Object> mf = (Map<String, Object>) toJson(field.getType());
        mf.put("name", field.getName());
        list.add(mf);
      }
      map.put("fields", list);
      map.put("nullable", node.isNullable());
    } else {
      map.put("type", node.getSqlTypeName().name());
      map.put("nullable", node.isNullable());
      if (node.getComponentType() != null) {
        map.put("component", toJson(node.getComponentType()));
      }
      RelDataType keyType = node.getKeyType();
      if (keyType != null) {
        map.put("key", toJson(keyType));
      }
      RelDataType valueType = node.getValueType();
      if (valueType != null) {
        map.put("value", toJson(valueType));
      }
      if (node.getSqlTypeName().allowsPrec()) {
        map.put("precision", node.getPrecision());
      }
      if (node.getSqlTypeName().allowsScale()) {
        map.put("scale", node.getScale());
      }
    }
    return map;
  }
Hive extension of RelJson.
Implement json serialization of types which are not support by Calcite 1.21.0.
This class can be removed when Calcite is upgraded to 1.23.0
ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/HiveRelJson.java