Flattening multiple arrays from a single SQL Server record in Azure Data Factory (ADF) Mapping Data Flow can be challenging, but it's definitely achievable.
Steps to Flatten Multiple Arrays
Use the Flatten Transformation:
In ADF Mapping Data Flow, use the Flatten transformation to unroll array values inside hierarchical structures like JSON into individual rows. This process is known as denormalization
You can unroll multiple arrays in a single Flatten transformation by clicking the plus (+) button next to the "Unroll by" property to add more arrays.
Configure the Flatten Transformation:
Unroll by: Select the arrays you want to unroll. The output data will have one row per item in each array.
Unroll root: Optionally, select an array as your unroll root. This must be an array of complex objects that either is or contains the unroll by array.
Use Meta Functions:
Utilize ADF's meta functions like name
and type
to find arrays to unroll in your data using patterns.
MapIndex Function:
For correlating values between multiple arrays, use the mapIndex
function. This function helps merge arrays together and then flatten them into a relational form
Example: mapIndex(utcCreated, @(utcCreated = #item, utcUpdated = utcUpdated[#index], batchId = batchId[#index], batchStatus = batchStatus[#index]))
.