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

Create a ForkRecord processor

    XMLWordPrintableJSON

Details

    • New Feature
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • None
    • 1.7.0
    • Extensions
    • None

    Description

      I'd like a way to fork a record containing an array of records into multiple records, each one being an element of the array. In addition, if configured to, I'd like the option to add to each new record the parent fields.

      For example, if I've:

      [{
      	"id": 1,
      	"name": "John Doe",
      	"address": "123 My Street",
      	"city": "My City", 
      	"state": "MS",
      	"zipCode": "11111",
      	"country": "USA",
      	"accounts": [{
      		"id": 42,
      		"balance": 4750.89
      	}, {
      		"id": 43,
      		"balance": 48212.38
      	}]
      }, 
      {
      	"id": 2,
      	"name": "Jane Doe",
      	"address": "345 My Street",
      	"city": "Her City", 
      	"state": "NY",
      	"zipCode": "22222",
      	"country": "USA",
      	"accounts": [{
      		"id": 45,
      		"balance": 6578.45
      	}, {
      		"id": 46,
      		"balance": 34567.21
      	}]
      }]
      

      Then, I want to generate records looking like:

      [{
      	"id": 42,
      	"balance": 4750.89
      }, {
      	"id": 43,
      	"balance": 48212.38
      }, {
      	"id": 45,
      	"balance": 6578.45
      }, {
      	"id": 46,
      	"balance": 34567.21
      }]
      

      Or, if parent fields are included, looking like:

      [{
      	"name": "John Doe",
      	"address": "123 My Street",
      	"city": "My City", 
      	"state": "MS",
      	"zipCode": "11111",
      	"country": "USA",
      	"id": 42,
      	"balance": 4750.89
      }, {
      	"name": "John Doe",
      	"address": "123 My Street",
      	"city": "My City", 
      	"state": "MS",
      	"zipCode": "11111",
      	"country": "USA",
      	"id": 43,
      	"balance": 48212.38
      }, {
      	"name": "Jane Doe",
      	"address": "345 My Street",
      	"city": "Her City", 
      	"state": "NY",
      	"zipCode": "22222",
      	"country": "USA",
      	"id": 45,
      	"balance": 6578.45
      }, {
      	"name": "Jane Doe",
      	"address": "345 My Street",
      	"city": "Her City", 
      	"state": "NY",
      	"zipCode": "22222",
      	"country": "USA",
      	"id": 46,
      	"balance": 34567.21
      }]
      

      Attachments

        1. TestForkRecord.xml
          28 kB
          Pierre Villard

        Issue Links

          Activity

            People

              pvillard Pierre Villard
              pvillard Pierre Villard
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: