azureazure-data-factory

ADF expression to convert array to comma separated string


This appears to be pretty basic but I am unable to find a suitable pipeline expression function to achieve this.

I have set an array variable VAR1 with the following value, which is an output from a SQL Lookup activity in an ADF pipeline:

[
    {
        "Code1": "1312312"
    },
    {
        "Code1": "3524355"
    }
]

Now, I need to convert this into a comma separated string so I can pass it to a SQL query in the next activity - something like:

"'1312312','3524355'"

I am unable to find an expression function to iterate over the array elements, nor convert an array to a string. The only pipeline expression functions I see are to convert string to array and not the other way around.

Am I missing something basic? How can this be achieved?


Solution

  • I got it working using a ForEach loop activity to iterate over my array and use a Set Variable task with a concat expression function to create my comma separated string.

    Wish they had an iterator function in the expression language itself, that would have made it much easier.