dan-s1 commented on PR #9485:
URL: https://github.com/apache/nifi/pull/9485#issuecomment-2462997366

   @exceptionfactory I had an idea to limit the scope of this change to only 
`JsonTreeReader` and I would like to have your feedback. My idea is to keep 
@pvillard31 changes in JsonTreeRowRecordReader.java for trimming the schema but 
change lines 129-133
   from 
   ```
   @Override
       protected Record convertJsonNodeToRecord(final JsonNode jsonNode, final 
RecordSchema schema, final boolean coerceTypes, final boolean dropUnknownFields)
               throws IOException, MalformedRecordException {
           return convertJsonNodeToRecord(jsonNode, schema, coerceTypes, 
dropUnknownFields, null);
       }
   ```
   to
   ```
   @Override
       protected Record convertJsonNodeToRecord(final JsonNode jsonNode, final 
RecordSchema schema, final boolean coerceTypes, final boolean dropUnknownFields)
               throws IOException, MalformedRecordException {
           return convertJsonNodeToRecord(jsonNode, schema, coerceTypes, 
!this.schemaInferred || dropUnknownFields, null);
       }
   ```
   where `schemaInferred` is a boolean calculated in `JsonTreeReader` in method 
`storePropertyValues` with
          ` this.schemaInferred = 
INFER_SCHEMA.getValue().equals(context.getProperty(SCHEMA_ACCESS_STRATEGY).getValue());`
   
   and it is passed to `JsonTreeRowRecordReader` by expanding its constructor 
to take this flag.
   
   This would thereby ensure whenever a schema is specified unknown fields are 
not kept.
   Please let me know your thoughts.
   
   
   


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

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to