You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hudi.apache.org by GitBox <gi...@apache.org> on 2020/04/05 15:16:32 UTC

[GitHub] [incubator-hudi] pratyakshsharma commented on a change in pull request #1427: [HUDI-727]: Copy default values of fields if not present when rewriting incoming record with new schema

pratyakshsharma commented on a change in pull request #1427: [HUDI-727]: Copy default values of fields if not present when rewriting incoming record with new schema
URL: https://github.com/apache/incubator-hudi/pull/1427#discussion_r403715629
 
 

 ##########
 File path: hudi-common/src/main/java/org/apache/hudi/common/util/HoodieAvroUtils.java
 ##########
 @@ -214,6 +218,21 @@ private static GenericRecord rewrite(GenericRecord record, Schema schemaWithFiel
     return newRecord;
   }
 
+  /*
+  This function takes the union of all the fields except hoodie metadata fields
+   */
+  private static List<Field> getAllFieldsToWrite(Schema oldSchema, Schema newSchema) {
+    Set<Field> allFields = new HashSet<>(oldSchema.getFields());
+    List<Field> fields = new ArrayList<>(oldSchema.getFields());
+    for (Schema.Field f : newSchema.getFields()) {
+      if (!allFields.contains(f) && !isMetadataField(f.name())) {
+        fields.add(f);
+      }
+    }
+
 
 Review comment:
   fixed.

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