Hey Yernaidu,
Thanks for posting your question on the Q&A portal! I see you're working with a nested time-series JSON and trying to flatten it in Azure Data Factory mapping data flow before loading it into Azure SQL. Let me walk you through how to do this step by step in a simple way.
First, in your data flow, you'll need to use the flatten transformation to handle the nested arrays. Since your JSON has dates as keys and arrays of objects as values, we'll need to first convert this structure into rows.
Source setup: In your source dataset, make sure you're reading the JSON file or API response correctly. Set the JSON file path or API endpoint, and ensure the format is set to JSON. You can check the microsoft documentation on JSON datasets in ADF here.
Flatten transformation: After the source, add a flatten transformation. Here, you'll want to unroll the nested arrays under each date. Since your dates are dynamic keys, you might need to use a derived column first to normalize the structure. For example, you can use an expression to convert the date keys into a column like reportDate
and then unroll the arrays. The flatten transformation docs are here.
Handling empty arrays: For dates with empty arrays (like "2023-07-30": []), you can use a conditional split to either keep them as-is or filter them out. If you want to keep them (as shown in your goal), you might need to add a derived column to mark them before splitting.
Mapping fields: Once flattened, map the fields (breakdown
, contacts
, customers
) to your Azure SQL table columns. If a date has no entries, you can use a select transformation to ensure those rows still appear with null values.
Sink to Azure SQL: Finally, configure your sink to write to Azure SQL. Make sure the table structure matches your output (reportDate, breakdown, contacts, customers). The ADF SQL sink docs are here.
A quick tip, if the JSON structure is tricky, you might want to use a data flow script or pre-processing with a web activity to reshape it before the data flow.
Hope this helps!
Best regards,
Alex
P.S. If my answer help to you, please Accept my answer
PPS That is my Answer and not a Comment
https://ctrlaltdel.blog/