You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@nifi.apache.org by "Mark Payne (JIRA)" <ji...@apache.org> on 2018/05/02 13:07:00 UTC

[jira] [Updated] (NIFI-5138) JSON Record Readers providing wrong schema to sub-records when there is a CHOICE of multiple RECORD types

     [ https://issues.apache.org/jira/browse/NIFI-5138?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Mark Payne updated NIFI-5138:
-----------------------------
    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:
{code:java}
{
  "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" }]
       }]
     }
  ]
}{code}
 

If I then have the following JSON:
{code:java}
{
  "id": "1234",
  "child": {
      "id": "4321"
  }
}{code}
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.

 

  was:
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:
{code:java}
{
  "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" }]
    }]
  ]
}{code}
 

If I then have the following JSON:
{code:java}
{
  "id": "1234",
  "child": {
      "id": 4321"
  }
}{code}
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.

 


> JSON Record Readers providing wrong schema to sub-records when there is a CHOICE of multiple RECORD types
> ---------------------------------------------------------------------------------------------------------
>
>                 Key: NIFI-5138
>                 URL: https://issues.apache.org/jira/browse/NIFI-5138
>             Project: Apache NiFi
>          Issue Type: Bug
>          Components: Extensions
>            Reporter: Mark Payne
>            Assignee: Mark Payne
>            Priority: Major
>
> 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:
> {code:java}
> {
>   "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" }]
>        }]
>      }
>   ]
> }{code}
>  
> If I then have the following JSON:
> {code:java}
> {
>   "id": "1234",
>   "child": {
>       "id": "4321"
>   }
> }{code}
> 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.
>  



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)