Hierarchical output structure editor - 8.0

Talend Data Mapper User Guide

Version
8.0
Language
English
Product
Talend Big Data Platform
Talend Data Fabric
Talend Data Management Platform
Talend Data Services Platform
Talend MDM Platform
Talend Real-Time Big Data Platform
Module
Talend Studio
Content
Design and Development > Designing Jobs
Last publication date
2024-03-28
The flat to hierarchical map feature allows you to define a hierarchical output structure.

The examples in the following table use the CSV sample provided in Creating a hierarchical map from a flat structure as input.

Feature Description Example

Add GroupBy

Arranges the children elements into a set of groups based on the value of the selected GroupBy element.

If a single element is selected, an array with all unique values for this element is created.

If multiple elements are selected, the first child element in the selection is automatically used as the GroupBy element. You can change it by right-clicking a child element and clicking Select as GroupBy element.

  • If you select the Gender element and click Add GroupBy, the output looks like this:
    "Gender": [
      "female",
      "male"
    ]
  • If you select the Gender and Name elements, the output looks like this:
    "Oscars": [
      {
        "Gender": "female",
        "Name": "Jessica Tandy"
      },
      {
        "Gender": "male",
        "Name": "Daniel Day-Lewis"
      }
    ]

Add Array

Creates a collection of elements that loops on the input row element if it exists, and the input root element otherwise.

If a single element is selected, a primitive array containing the value of the element is created. If multiple elements are selected, an array of records is created.

When this feature is used on an element inside a GroupBy, it allows you to create groups.

  • If you select the Movie element and click Add Array, the array looks like this:
    "Movie": [
      "Driving Miss Daisy",
      "Misery",
      "The Silence of the Lambs"
    ]
  • If you select the Movie and Name elements, the array looks like this:
    "Movies": [
      {
        "Name": "Jessica Tandy",
        "Movie": "Driving Miss Daisy"
      },
      {
        "Name": "Kathy Bates",
        "Movie": "Misery"
      }
    ]

Add Record

Creates a record from the element(s) selected.

If you select the Movie and Year elements, the record looks like this:
"Movie_record": {
  "Year": "1990",
  "Movie": " Driving Miss Daisy"
}

Convert GroupBy/Array Item Type

Changes an array or a set of groups from a primitive item type to a record item type, or the other way around.
Note: This option is available on a record item only when the records contains a single element.
If you create an array from the Movie element and click Convert GroupBy/Array Item Type, the array looks like this:
"Movie_array": [
  {
    "Movie": "Driving Miss Daisy"
  },
  {
    "Movie": "Misery"
  },
  {
    "Movie": "The Silence of the Lambs"
  }
]

Convert to Array

Converts a set of groups into an array.

If you convert groups containing the Gender and Name elements grouped by Gender into an array, the array looks like this:
"Gender_array": [
  {
    "Gender": "female",  
    "Name": " Jessica Tandy"
  },
  {
    "Gender": "female",
    "Name": " Kathy Bates"
  },
  {
    "Gender": "male",
    "Name": " Daniel Day-Lewis"
  },    
  {
    "Gender": "male",
    "Name": " Jeremy Irons"
  }
]

Convert to GroupBy

Converts an array into groups.

By default, the first child element in the array is automatically selected as the GroupBy element. You can change it by right-clicking a child element and clicking Select as GroupBy element.

You can also convert the root element into a set of groups.

If you convert the root element to a group and select Year as the GroupBy element, the output looks like this:
[{
    "row": [
        {
            "Index": "1",
            "Gender": "female",
            "Year": "1990",
            "Age": "80",
            "Name": " Jessica Tandy",
            "Movie": " Driving Miss Daisy"
        },
        {
            "Index": "28",
            "Gender": "male",
            "Year": "1990",
            "Age": "32",
            "Name": " Daniel Day-Lewis",
            "Movie": " My Left Foot"
        }
    ]
}]
Tip: You can move elements using drag and drop, and you can duplicate elements in the output structure by copying and pasting them. When adding or duplicating elements, make sure the element names are unique to avoid errors.