insert file name in sink table

akash agrawal 1 Reputation point
2022-02-19T10:29:02.957+00:00

Hi, i have created a pipeline where it is fetching multiple files from Datalake using Getmetadata Activity. Then we are passing these files into Foreach Activity where we are transforming the data using dataflow and loading into sink table. But we are not able to load the filename into sink table. Can you help me how we can achieve it.

  1. We are not using Copy Activity in for each.
  2. Created new SetVariable in ForEach which is holding the processing file name.
  3. I have created new column name in Source using Source option 'SourceFileName' but not not getting how to pass the variable value in it.
Azure Data Factory
Azure Data Factory
An Azure service for ingesting, preparing, and transforming data at scale.
10,718 questions
{count} votes

1 answer

Sort by: Most helpful
  1. ShaikMaheer-MSFT 38,441 Reputation points Microsoft Employee
    2022-02-21T13:47:51.557+00:00

    Hi @akash agrawal ,

    Thank you for posting query in Microsoft Q&A Platform.

    As per my understanding, you would like to have filename column on top of your source columns and load them to sink table. Please correct me if my understanding is wrong.

    You can achieve this by having a parameter in data flow to take file name as value. We should have derived column transformation inside dataflow to add new column for file name.

    Please check below screenshots for clear idea.

    Step1: fileName parameter inside data flow to take file name value from data flow activity.
    176407-image.png

    Step2: Derived column transformation to add new column on top of source columns for file name column.
    176451-image.png

    Step3: In sink transformation make sure to map this new column with desired sink table column.
    176452-image.png

    Step4: Data flow activity, pass value of file in to data flow parameter.
    176436-image.png

    Hope this helps. Please let us know if any further queries. Thank you.


    Please consider hitting Accept Answer. Accepted answers helps community as well.


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.