The function 'length' expects its parameter to be an array or a string. The provided value is of type 'Object'.


{tocify} $title={Table of Contents}


Error/Issue:


For the last post,  Getting started with ADF - Loading data in SQL Tables from multiple parquet files dynamically , I created a pipeline and clicked on  validate and No errors were found.


pipeline validated



However when I triggered the pipeline for testing, got below an error

The function 'length' expects its parameter to be an array or a string. The provided value is of type 'Object'.


                       


Why it happened


The function 'length' expects its parameter to be an array or a string. The provided value is of type 'Object'.


It was ForEach activity which gave us the error, and as the error says Object was given as input to it

incorrect input to for each loop

Wait.. we want output of lookup activity to be provided as input to For Each so that we can iterate through it.

But why it's  not allowing/accepting it?

How ForEach Loop works in Azure Data Factory



It is one of the control flow activity which can be used in a scenario where you have to iterate through some collection, list, array etc

And you perform or carry out same action/task for each iteration by using some value from the current item.

In ForEach whatever input (array/list/collection) you provide to it, is referenced using term called as items and the records in it as item.

Thus it expects its input parameter to be an array or a string.

And what I had provided - @activity('ConfigLookup').output

Let's see what does @activity('ConfigLookup').output contains

output of lookup activity



Output is a JSON Object having result of the activity and all the metadata about the activity whereas Value is a JSON array inside Output having actual result of the lookup activity.



What to do


Firstly make a note, even validated pipeline can give you surprises  😏.

So, over here correct input to be provided to ForEach is  

                @activity('ConfigLookup').output.value


That's it... pipeline happily executed then after.

If you have questions or suggestions, feel free to do in comments section below !!!


Do share if you find this helpful .......
 
                          Knowledge Sharing is Caring !!!!!!




Learn More about some more Azure Data Factory errors



    4 Comments

    If you have any suggestions or questions or want to share something then please drop a comment

    1. I was stuck for over 24 hours on this portion. I tried researching everything I could and still couldnt get to the results. I can't thank you enough for your help. Because of your amazing post, my work became a breeze.

      ReplyDelete
    2. Thank you so much for sharing this info. I was struck was nearly 1 hr and this saved me. thank you so much

      ReplyDelete
    3. Thank you so much. My problem get fixed.

      ReplyDelete
    4. i am still having issues, i am trying to read following columns vie lookup and wanted to pass this to foreach "ID
      Table_Name
      Source_Table_DB
      Source_Table
      Taget_Table_DB
      Target_Table
      Source_Query
      Frequency.

      is this possible to pass multiple columns to foreach? as i have previously done with 1 column successfully.

      ReplyDelete
    Previous Post Next Post