You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@gobblin.apache.org by GitBox <gi...@apache.org> on 2019/11/05 21:00:08 UTC

[GitHub] [incubator-gobblin] arjun4084346 commented on a change in pull request #2792: [GOBBLIN-933] add support for array of unions in json schema

arjun4084346 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_r342794498
 
 

 ##########
 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:
   the existing code only supports two types.
   https://github.com/apache/incubator-gobblin/blob/master/gobblin-core/src/main/java/org/apache/gobblin/converter/avro/JsonRecordAvroSchemaToAvroConverter.java#L93

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services