autumnust commented on a change in pull request #2792: [GOBBLIN-933] add 
support for array of unions in json schema
URL: https://github.com/apache/incubator-gobblin/pull/2792#discussion_r342770317
 
 

 ##########
 File path: 
gobblin-core/src/main/java/org/apache/gobblin/converter/avro/JsonElementConversionWithAvroSchemaFactory.java
 ##########
 @@ -210,4 +215,49 @@ public Schema schema() {
       return this.schema;
     }
   }
+
+  public static class UnionConverter extends ComplexConverter {
+    private final Schema firstSchema;
+    private final Schema secondSchema;
+    private final JsonElementConverter firstConverter;
+    private final JsonElementConverter secondConverter;
+
+    public UnionConverter(String fieldName, boolean nullable, String 
sourceType, Schema schemaNode,
+        WorkUnitState state, List<String> ignoreFields) throws 
UnsupportedDateTypeException {
+      super(fieldName, nullable, sourceType);
+      List<Schema> types = schemaNode.getTypes();
+      if (types.size() != 2) {
+        throw new RuntimeException("Unions must be size 2.");
 
 Review comment:
   This is not a valid assumption in the context of Avro schema. What's the 
reason to enforce `size == 2` for union here?

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to