reubenvanammers commented on a change in pull request #11955:
URL: https://github.com/apache/beam/pull/11955#discussion_r437814700



##########
File path: sdks/java/core/src/main/java/org/apache/beam/sdk/util/RowJson.java
##########
@@ -185,18 +186,25 @@ private RowJsonDeserializer(Schema schema) {
       this.schema = schema;
     }
 
+    public RowJsonDeserializer allowMissingFields(Boolean allowMissing){
+      this.allowMissingFields = allowMissing;
+      return this;
+  }
+
     @Override
     public Row deserialize(JsonParser jsonParser, DeserializationContext 
deserializationContext)
         throws IOException {
 
       // Parse and convert the root object to Row as if it's a nested field 
with name 'root'
       return (Row)
           extractJsonNodeValue(
-              FieldValue.of("root", FieldType.row(schema), 
jsonParser.readValueAsTree()));
+              FieldValue.of("root", FieldType.row(schema), 
jsonParser.readValueAsTree(), allowMissingFields));
     }
 
+  
+
     private static Object extractJsonNodeValue(FieldValue fieldValue) {
-      if (!fieldValue.isJsonValuePresent()) {

Review comment:
       I initially thought about this, then changed to putting it into the 
FieldValue because extractJsonNodeValue was static. Now that you mention it, I 
believe it is probably neater to just check this.allowMissing fields and change 
the method to non-static.




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


Reply via email to