Extract Elements from Hierarchical Data
You can extract elements of a primitive or complex data type from hierarchical data. Use the Extract from Complex Port wizard in the Developer tool to perform the conversion.
Based on the data type of the elements in the complex port that you select, the wizard performs the following conversions:
- •If the elements are of primitive data types, the wizard converts the element to a relational data.
- •If the elements are of complex data types, the wizard converts the element to a hierarchical data.
The wizard adds an Expression transformation that contains one or more extracted ports. The number of elements that you select to extract determine the number of output ports in the transformation. The data type of the element determines the data type of the output port. The expression in the output ports use complex operators to extract elements from the complex port.
The following table describes the wizard conversions based on the data type of the complex port that you select:
Complex Port Data Type | Wizard Conversion |
---|
array | Relational data. If you specify an array index, the wizard extracts an element in the array. Default is 0. The wizard extracts the first element of the array. Hierarchical data. If you do not specify an array index, the wizard extracts the entire array. |
struct | Relational data. The wizard extracts the element in the struct that you selected. |
array of structs | Relational data. If you select an element in the struct, the wizard extracts the element. The wizard requires an array index value. Default is 0. Hierarchical data. If you select the array and specify an array index, the wizard extracts the struct element in the array. If you do not specify an array index, the wizard extracts the entire array. |
array of maps | Relational data. If you select the key or value element in the array and specify an array index, the wizard extracts the element. Hierarchical data. If you select the array and specify an array index, the wizard extracts the map element in the array. If you do not specify an array index, the wizard extracts the entire array. |
struct of structs | Relational data. If you select an element in the parent or the child struct, the wizard extracts the element. Hierarchical data. If you select the parent struct or child struct, the wizard extracts that struct. |
struct of maps | Hierarchical data. If you select the map element, the wizard extracts the map data. If you select the struct, the wizard extracts the struct data in another port. |
Extracting Elements from a Complex Port
Use the Extract from Complex Port wizard to extract elements from hierarchical data.
1. In the transformation, select a complex port from which you want to extract elements.
2. Right-click the selected ports, and select Hierarchical Conversions > Extract from Complex Port.
The Extract from 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 that you want to extract.
4. To extract an array element, specify an array index in the Array Index column.
If you delete the array index, the wizard extracts the entire array. To extract an element in the struct from a complex port for an array of structs, you must specify an array index value.
5. Click Finish.
You can see the following changes in the mapping:
- •The mapping contains a new Expression transformation Extract_<complex_port_name> with the following ports:
- - The complex port from which you want to extract elements as the input port.
- - One or more output ports for the extracted elements. The number of elements that you selected to extract determines the number of output ports in the transformation.
- - A dynamic port with ports from the upstream transformation.
- •The output ports contain expressions that use complex operators to extract elements.
The following image shows the expressions for the output ports in the Expression column on the Ports tab: