Can't convert table value to string in ADF

Viewed 50

I'm trying to loop over data in an SQL table, but when I'm trying to use the value inside a foreach loop action using the @item() i get the error:

"Failed to convert the value in 'table' property to 'System.String' type. Please make sure the payload structure and value are correct."

So the row value can't be converted to a string. Could that be my problem? and if so, what can I do about it?

Here is the pipeline:

enter image description here

enter image description here

enter image description here

enter image description here

enter image description here

1 Answers

I reproduced the above scenario with SQL table containing table names in lookup and csv files from ADLS gen2 in copy activity and got the same error.

enter image description here

The above error arises when we gave the lookup output array items directly into a string parameter inside ForEach.

If we look at the below lookup output,

enter image description here

The above value array is not a normal array, it is an array of objects. So, @item() in 1st iteration of ForEach means one object { "tablename": "sample1.csv" }. But our parameter expects a string value and that's why it is giving the above error.

To resolve this, give @item().tablename which will give our table names in every iteration inside ForEach.

My repro for your reference:

enter image description here

I have given same in sink also and this is my output.

Pipeline Execution

enter image description here

Copied data in target

enter image description here

Related