[ 
https://issues.apache.org/jira/browse/GOBBLIN-957?focusedWorklogId=343895&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-343895
 ]

ASF GitHub Bot logged work on GOBBLIN-957:
------------------------------------------

                Author: ASF GitHub Bot
            Created on: 15/Nov/19 00:17
            Start Date: 15/Nov/19 00:17
    Worklog Time Spent: 10m 
      Work Description: shirshanka commented on pull request #2806: 
GOBBLIN-957: Add recursion eliminating converter for Avro
URL: https://github.com/apache/incubator-gobblin/pull/2806#discussion_r346610964
 
 

 ##########
 File path: gobblin-utility/src/main/java/org/apache/gobblin/util/AvroUtils.java
 ##########
 @@ -935,4 +941,141 @@ public static Schema overrideNameAndNamespace(Schema 
input, String nameOverride,
     return newSchema;
   }
 
+  @Builder
+  @ToString
+  public static class SchemaEntry {
+    @Getter
+    final String fieldName;
+    final Schema schema;
+    String fullyQualifiedType() {
+      return schema.getFullName();
+    }
+  }
+
+  /**
+   * Drop recursive fields from a Schema. Recursive fields are fields that 
refer to types that are part of the
+   * parent tree.
+   * e.g. consider this Schema for a User
+   * {
+   *   "type": "record",
+   *   "name": "User",
+   *   "fields": [
+   *     {"name": "name", "type": "string",
+   *     {"name": "friend", "type": "User"}
+   *   ]
+   * }
+   * the friend field is a recursive field. After recursion has been 
eliminated we expect the output Schema to look like
+   * {
+   *    "type": "record",
+   *    "name": "User",
+   *    "fields": [
+   *    {"name": "name", "type": "string"}
+   *    ]
+   * }
+   *
+   * @param schema
+   * @return a Pair of (The transformed schema with recursion eliminated, A 
list of @link{SchemaEntry} objects which
+   * represent the fields that were removed from the original schema)
+   */
+  public static Pair<Schema, List<SchemaEntry>> dropRecursiveFields(Schema 
schema) {
 
 Review comment:
   added
 
----------------------------------------------------------------
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]


Issue Time Tracking
-------------------

    Worklog Id:     (was: 343895)
    Time Spent: 1.5h  (was: 1h 20m)

> Support automatic recursion removal from schemas
> ------------------------------------------------
>
>                 Key: GOBBLIN-957
>                 URL: https://issues.apache.org/jira/browse/GOBBLIN-957
>             Project: Apache Gobblin
>          Issue Type: Improvement
>            Reporter: Shirshanka Das
>            Assignee: Shirshanka Das
>            Priority: Major
>              Labels: avro
>          Time Spent: 1.5h
>  Remaining Estimate: 0h
>
> Analytics engines like Hive etc cannot handle recursive schemas: schemas 
> where inner fields can refer to the wrapping type. 
> This Jira proposes that we provide support for automatic recursion removal in 
> data during data ingestion. 
> The simple proposal is to just drop the fields in the schema that introduce 
> the recursion. 
> e.g.  (pseudo-schema)
> User { 
>  string name;
>  User friend;
> }
> gets converted to :
> User { 
>    string name;
> }
>  
> A more sophisticated solution would be to do one or two levels of 
> "schema-unrolling" before dropping data. 
> e.g. 
> output schema with one-level unrolling would look like: 
> User { 
>    string name;
>    User1 friend;
> }
> User 1 { 
>     string name;
>   }
>  
>  
>  
>  
>  
>  



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to