You can flatten fields of a complex data type in mappings that run on the Spark engine. You flatten fields in the
Normalizer
view to modify hierarchical data that passes through a complex port.
The output of the flatten action depends on the complex data type. When you flatten an array or struct data type, the Normalizer transformation creates a row for each element in the complex data type. When you flatten a map data type, the Normalizer transformation creates two columns for the map key and map value elements.
The flatten action on a nested data type extracts elements at the first-level. To flatten a nested data type at all levels, use the
Flatten Complex Port
hierarchical conversion wizard in the Developer tool. The
Flatten All
option extracts elements at each level and returns relational data of primitive data type. For more information about hierarchical conversion wizards, see the
Data Engineering Integration User Guide
.
The flatten action changes the value of Occurs column in the Normalizer view to Auto and adds a flatten icon next to the flattened field. The value Auto indicates that the transformation flattens all the elements of the complex data type.
The following image shows a struct that is flattened to a string field with a flatten icon next to it and the Occurs value as Auto:
You cannot flatten a multi-occurring field. For example, you cannot flatten an array field with Occurs value as 2.
The following image shows a multi-occurring field of an array data type that you cannot flatten: