Hi @Anonymous ,
Welcome to Microsoft Q&A platform and thanks for posting your question here.
As I understand your question, you are trying to copy JSON into SQL table by flattening the complex data.
First of all, row[] has a single nested array within , however at the end of it, there seems to be ',' which is not required here. For processing it , I am removing one level of array . Instead of row[[]] , I am providing row[] . You can follow the same steps on the original source data:
- Add two source transformations pointing to the same source json. Select 'Array of documents' in the json settings for both the sources.
- Add flatten transformations to each of the sources . For one flatten transformation, select
rows[]
to unroll by and for the other one, selectcolumns[]
to unroll by.
- Add surrogate Key transformation to each of them to create a new incremental column called
rownum
- Add Join transformation to join the two sources based on
Id
andRowNum
- Use Select transformation to remove unwanted columns after the join
- Use Pivot transformation and group by using
id
column . In the Pivot key tab, usename
column and in the pivoted columns , provide aggregate function like min(rows) or max(rows) or avg(rows). - Go to the Data preview tab of Pivot transformation and select 'Map drifted' option. It will add another derived column automatically . Select 'Id' column and remove it and sort other columns as per the need.
- Add SQL dataset in sink transformation to load the data to SQL table.
Hope this will help. Please let us know if any further queries.
------------------------------
- Please don't forget to click on
or upvote
button whenever the information provided helps you.
Original posters help the community find answers faster by identifying the correct answer. Here is how - Want a reminder to come back and check responses? Here is how to subscribe to a notification
- If you are interested in joining the VM program and help shape the future of Q&A: Here is how you can be part of Q&A Volunteer Moderators