rdblue commented on code in PR #12346: URL: https://github.com/apache/iceberg/pull/12346#discussion_r1994444312
########## core/src/main/java/org/apache/iceberg/SchemaParser.java: ########## @@ -141,11 +145,39 @@ static void toJson(Types.MapType map, JsonGenerator generator) throws IOExceptio } static void toJson(Type.PrimitiveType primitive, JsonGenerator generator) throws IOException { - generator.writeString(primitive.toString()); + switch (primitive.typeId()) { + case GEOMETRY: + Types.GeometryType geometryType = (Types.GeometryType) primitive; + generator.writeStartObject(); + generator.writeStringField(TYPE, GEOMETRY); + if (!geometryType.crs().isEmpty()) { + generator.writeStringField(CRS, geometryType.crs()); + } + generator.writeEndObject(); + break; + + case GEOGRAPHY: + Types.GeographyType geographyType = (Types.GeographyType) primitive; + generator.writeStartObject(); + generator.writeStringField(TYPE, GEOGRAPHY); + if (!geographyType.crs().isEmpty()) { + generator.writeStringField(CRS, geographyType.crs()); + } + if (geographyType.algorithm() != null) { + generator.writeStringField(ALGORITHM, geographyType.algorithm().name()); + } + generator.writeEndObject(); + break; + + default: + generator.writeString(primitive.toString()); + } } static void toJson(Type type, JsonGenerator generator) throws IOException { - if (type.isPrimitiveType() || type.isVariantType()) { + if (type.isPrimitiveType()) { + toJson(type.asPrimitiveType(), generator); + } else if (type.isVariantType()) { Review Comment: This should not change. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: issues-unsubscr...@iceberg.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@iceberg.apache.org For additional commands, e-mail: issues-h...@iceberg.apache.org