UHutch
UHutch

Reputation: 1

Dynamic "Unroll by" in Flatten activity in Synapse Data flow

I have three XML files that are similar in term of data hierarchy. Is it possible to use a dynamic 'Unroll by' when using flatten activity in a Synapse Data flow? I tried creating a parameter to hold an 'Unroll by' text. When I use that parameter in the 'Unroll by' section and then click "Reset" in the 'Input column', nothing shows up in the "Input column" section. I'm expecting to see the data in the 'Data Preview' tab but it threw an error ''flatten1'(Line 16/Col 8): unrollby should be a column path without any expression" when I tried to preview it. I read the post, 'Dynamic Flatten - Data Flow ADF', but it's still unclear on how the dynamic 'Unroll by' works.

[First file](https://i.sstatic.net/FZhJc.png) => first file
[Second file](https://i.sstatic.net/oSfWk.png) => second file
[Third file](https://i.sstatic.net/WdWHa.png) => thrid file

Upvotes: 0

Views: 419

Answers (1)

Rakesh Govindula
Rakesh Govindula

Reputation: 11454

As your source files are of same structure, you can achieve your requirement by using dataset parameters and for loop.

First create a string type dataset parameter for the file name of source xml dataset and use in the file path like below. Here my source files are from ADLS gen2. Give this dataset to the dataflow.

enter image description here

Pass your file names list to for loop and inside for loop take dataflow activity, pass the xml file name to the dataset parameter like below.

enter image description here

Build your dataflow like this. Flatten transformation needs a schema to work in the debug of the dataflow.

So, import the schema in the source mapping, but it will ask the source dataset file name parameter value. As your structure is same for every file, just pass any one file name of your 3 files and the schema will be imported.

enter image description here

Use this schema in the flatten settings to flatten the array.

enter image description here

This will give the data preview of the sample file.

enter image description here

To do this for all source files, you need to debug the pipeline. Give your sink dataset and execute the pipeline. Here, I have transformed each source xml file to separate sink files using the data flow parameter and these are result files.

enter image description here

Upvotes: 0

Related Questions