lukecwik commented on code in PR #24271:
URL: https://github.com/apache/beam/pull/24271#discussion_r1037622529
##########
sdks/java/core/src/main/java/org/apache/beam/sdk/schemas/utils/JsonUtils.java:
##########
@@ -73,6 +78,87 @@ public String apply(Row input) {
};
}
+ public static Schema beamSchemaFromJsonSchema(String jsonSchemaStr) {
+ org.everit.json.schema.ObjectSchema jsonSchema =
jsonSchemaFromString(jsonSchemaStr);
+ return beamSchemaFromJsonSchema(jsonSchema);
+ }
+
+ private static Schema
beamSchemaFromJsonSchema(org.everit.json.schema.ObjectSchema jsonSchema) {
+ Schema.Builder beamSchemaBuilder = Schema.builder();
+ for (String propertyName : jsonSchema.getPropertySchemas().keySet()) {
+ org.everit.json.schema.Schema propertySchema =
+ jsonSchema.getPropertySchemas().get(propertyName);
+ if (propertySchema == null) {
+ throw new IllegalArgumentException("Unable to parse schema " +
jsonSchema.toString());
+ }
+ if (propertySchema instanceof org.everit.json.schema.ObjectSchema) {
Review Comment:
The conversions for type to schema are short I think it would be simpler to
not add this indirection
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]