How to flat complex json data into sql db using copy activity?

THIMMAIAH GARI,PRASHANTH,, 201 Reputation points
2020-08-13T07:31:14.283+00:00

Hi Team,

I have data with multiple arrays and inside multiple objects. I am using copy activity to load into database. I Have used collection reference to convert the data. But it's not helping much, out of 1000 users data ,either I get all users with only 'seconds viewed' information($['elements'][0]['activities']) or Only one user with other activities information(seconds views,completion,progress percentage) by changing 'collection reference'

Please provide proper cross-apply code.

Azure Data Factory
Azure Data Factory
An Azure service for ingesting, preparing, and transforming data at scale.
10,819 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. KranthiPakala-MSFT 46,502 Reputation points Microsoft Employee
    2020-08-13T20:22:55.707+00:00

    Hi @THIMMAIAH GARI,PRASHANTH,, ,

    Thanks for reaching out. Unfortunately, Copy activity is not a suitable activity for flattening nested/complex JSON array structures.

    In case if your source and sink data stores are any of the below (ADF Mapping dataflow activity supported data stores), then you can you use Mapping Dataflow activity which has Flatten transformation that can be used to take arrays from complex structures and generate hierarchical-to-relational and hierarchical-to-hierarichical computed columns, aggregations, mappings.

    In case if your data stores are not any of the Dataflow supported data sources, one possible way is to stage your data in one of the Data Flow supported data source and use the Flatten transformation to achieve your requirement.

    Please refer to this demonstration from Mark Kromer on how to use Flatten transformation in Mapping Data flow : https://www.youtube.com/watch?v=VY2tFQJoAXE

    Related info: ADF adds new hierarchical data handling and new flexibility for complex joins

    In case if you have any feedback or suggestion regarding copy activity functionality, I would recommend you to please share your thoughts in ADF user voice forum. All the feedback shared in this forum are actively monitored and reviewed by ADF engineering team.

    Hope this info helps. Do let us know if your have further query.

    ----------

    Thank you
    Please do consider to click on "Accept Answer" and "Upvote" on the post that helps you, as it can be beneficial to other community members.


  2. Kiran-MSFT 691 Reputation points Microsoft Employee
    2020-08-18T15:54:17.21+00:00

    If you have complex json and get the structure in dataflow, use the toString() function to get a string representation to insert into SQL.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.