Flatten Hierarchical Data
You can flatten elements of hierarchical data into relational data. Use the Flatten Complex Port wizard in the Developer tool to perform the conversion.
The wizard converts hierarchical data to relational data. When you have hierarchical data with nested data type, you can select specific elements or all elements of complex data type to flatten.
Based on the data type of the complex port, the wizard performs the following tasks:
- struct
- - Adds an Expression transformation with flattened output ports. The expression for the output ports uses the dot operator to extract elements in the struct.
- - Adds a final Expression transformation that contains a dynamic port with all ports from the upstream transformation including the flattened struct ports.
- array
- Adds a Normalizer transformation with flattened output ports. The wizard flattens the array field in the Normalizer view.
- Adds a final Expression transformation that contains a dynamic port with all ports from the upstream transformation including the flattened array ports.
- nested data type
- Adds one or more Expression and Normalizer transformations with flattened output ports. If you select a child element of a nested complex port, the wizard flattens both the parent and child elements.
- Adds a final Expression transformation that contains a dynamic port with all ports from the upstream transformation including the flattened ports.
Flattening a Complex Port
Use the Flatten Complex Port wizard to convert hierarchical data to relational data.
1. In the transformation, select a complex port that you want to flatten.
2. Right-click the selected ports, and select Hierarchical Conversions > Flatten Complex Port.
The Flatten Complex Port wizard appears with the list of elements in the complex port.
3. In the Select Elements column, select the check box for each element of a struct or an array data type that you want to extract.
If you select a child element of a nested complex port, the wizard automatically selects the parent element to flatten.
4. Optionally, click Flatten All to flatten all elements of struct or data type in the complex port.
The wizard selects all elements of struct or data type in the complex port to flatten.
5. Click Finish.
You can see the following changes in the mapping:
The following image shows an example of mapping changes: