Dynamically change column names in ADF

Poel van der, RE (Ron) 451 Reputation points
2021-06-11T15:44:51.367+00:00

Hi
How to dynamically change column names in Dataflow?

Suppose I get columns A,B,C from source and I want to change it Alpha, B, Comet.
Instead of selecting column A and C and then renaming, I want to do it by passing a string array for the input column names and a string array for the output column names. And then rename them.
['A','B','C'] and ['Alpha','B','Comet']

Is that possible?
Is it possible with hardcoding the positions of the names in the array?
Is it possible without hardcoding the positions of the names in the array?

regards
Ron

@MarkKromer-MSFT

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

2 answers

Sort by: Most helpful
  1. Kiran-MSFT 691 Reputation points Microsoft Employee
    2021-06-11T17:39:11.15+00:00

    Use a cache sink with this lookup data of columns. Then you can use this in pattern match in a derive transform and remap the columns.

    0 comments No comments

  2. Poel van der, RE (Ron) 451 Reputation points
    2021-06-14T07:55:13.433+00:00

    hI @Kiran-MSFT

    thnx for you answer.
    Let me explain a little bit more

    Suppose I have a JSON file with two separate arrays in it

    Array1 = OldNames
    Array2 = NewNames

    The arrays are used for renaming columns.
    For instance Array1 might contain three names, like A, B and C.
    Array2 might contain the names X1, Y1, Z1.
    In the end my pipeline / dataflow must rename attribute A to X1, B to Y1 and C to Z1.
    In a derived column activity you could work with the keyword ‘position’.

    But the issue is that each time another JSON file is input for this pipeline / data flow.
    Array1 and Array2 always contain the same number of attributes, but one time it might be 5, the other 2 and another time 10 as an example
    How then can we make this process dynamic, so that it will work regardless of the number of attributes in Array1 and Array2?

    regards
    Ron


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.