Uploaded image for project: 'Apache NiFi'
  1. Apache NiFi
  2. NIFI-5138

JSON Record Readers providing wrong schema to sub-records when there is a CHOICE of multiple RECORD types

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • None
    • 1.7.0
    • Extensions
    • None

    Description

      When the JSON Record Reader is used, if the schema provides a CHOICE of two different RECORD types for a sub-record, then the sub-record's schema ends up being an empty schema. This results in RecordPath's not properly evaluating. For example, with the schema below:

      {
        "name": "top", "namespace": "nifi",
        "type": "record",
        "fields": [
          { "name": "id", "type": "string" },
          { "name": "child", "type": [{
               "name": "first", "type": "record",
               "fields": [{ "name": "name", "type": "string" }]
             }, {
               "name": "second", "type": "record",
               "fields": [{ "name": "id", "type": "string" }]
             }]
           }
        ]
      }

       

      If I then have the following JSON:

      {
        "id": "1234",
        "child": {
            "id": "4321"
        }
      }

      The result is that the record returned has the correct schema. However, if I then call record.getValue("child") I am returned a Record object that has no schema.

      This results in the RecordPath "/child/id" returning a null value.

       

      Attachments

        Issue Links

          Activity

            People

              markap14 Mark Payne
              markap14 Mark Payne
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: