Big Data Management User Guide > Configuring Transformations to Process Hierarchical Data > Convert Relational or Hierarchical Data to Nested Struct Data
  

Convert Relational or Hierarchical Data to Nested Struct Data

You can convert relational or hierarchical data in one or more columns in two transformations to nested struct data. Use the Create Nested Complex Port wizard in the Developer tool to perform the conversion.
The wizard converts relational data from two tables to struct data with a nested data type definition.
For example, a relational table contains employee bank account details. Another table contains the bank details. You create a mapping to convert data in the two tables into a hierarchical format that the payment system can process. Select the ports in the two transformations and use the Create Nested Complex Port wizard. The wizard generates struct data that contains an array element for each bank. The array contains a struct element for the employee bank account details.
Relational input
The Emp_Details table contains the following columns: employee ID, name, address, bank id, and bank account number.
The Bank_Details table contains the following columns: bank id, bank name, SWIFT code.
Struct output
banks{
bank_swift:integer
[bank_name{account_number:integer,employee_id:integer,name:string,address:string]
}
The wizard performs the following tasks:

Creating A Nested Complex Port

Use the Create Nested Complex Port wizard to convert data that passes through one or more ports in two transformations to a struct data that references a nested data type definition. You specify the transformations from which the wizard creates the parent and child complex data type definitions.
    1. Open the mapping or mapplet in which you want to create a nested complex port.
    2. Press Ctrl and select the ports in the two transformations that you want to convert as elements of the nested complex port.
    The mapping contains two Read transformations and two Expression transformations. The Read transformations contain ports that pass employee and bank details. The Expression transformation shows the selected ports from which you want to create nested complex port.
    3. Right-click the selected ports, and select Hierarchical Conversions > Create Nested Complex Port.
    The Create Nested Complex Port wizard appears.
    The first page of the wizard contains the name of the transformations from which you selected the ports. You must choose the parent transformation and select the parent and child key. The first transformation is selected as the parent transformation by default. The first port in each transformation is selected as the join key by default.
    4. Choose the transformation that contains ports for the parent complex data type definition and select the join keys to join the tables.
    The image shows the second transformation as the parent transformation. The first port in each transformation is selected as the join key by default.
    5. Click Next.
    The wizard page to create child complex data type definition appears.
    The second page of the wizard shows a default name for the child complex data type definition. The page also displays the ports that will be added as the elements of the complex data type definition.
    6. Optionally, change the name of the child complex data type definition and make any changes to the elements.
    The image shows the changed name of the child complex data type definition and the list of elements to be added.
    7. Click Next.
    The wizard page to select group by port from the parent transformation appears.
    The third page of the wizard contains the Elements field and the Choose button to select the group by port from the parent transformation.
    8. Click Choose.
    The Ports dialog box appears.
    9. Select a group by port from the parent transformation and click OK.
    The selected port appears on the wizard page.
    The page displays the group by port that you selected.
    10. Click Next.
    The final wizard page to create parent complex data type definition and nested complex port appears.
    The last page of the wizard shows a default name for the parent complex data type definition. The page also displays the ports that will be added as the elements of the complex data type definition.
    11. Optionally, change the name of the parent complex data type definition and make any changes to the elements.
    You cannot delete the port that you selected as the group by port.
    The image shows the changed name of the parent complex data type definition and the list of elements to be added.
    12. Click Finish.
You can see the following changes in the mapping: