You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@beam.apache.org by GitBox <gi...@apache.org> on 2020/06/10 01:49:09 UTC

[GitHub] [beam] reubenvanammers commented on a change in pull request #11955: [BEAM-10220] add support for implicit nulls for converting between beam rows and json

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