ADF Copy Data Activity: XML Documents with only one item in list is not accepted as a list

Christian Dalen 6 Reputation points
2021-10-20T09:04:36.087+00:00

For a Data Copy Activity, when you have XML as source, it does not accept documents with only one item in the array as a valid array.
This occurs quite frequently for me when XML is the source and data is in many files. An array should consist of zero to many items and I cannot see it as anything else then a bug that a array must have at least two items to be considered an array for XML as a source.

Currently the only workaround is to have separate handling for files with one item and files with more than one.

Any solution to this?

Azure Data Factory
Azure Data Factory
An Azure service for ingesting, preparing, and transforming data at scale.
0 comments No comments
{count} vote

1 answer

Sort by: Most helpful
  1. MartinJaffer-MSFT 26,161 Reputation points
    2021-10-21T15:49:19.607+00:00

    Hello @Christian Dalen and welcome to Microsoft Q&A.

    I ran into a similar issue a while back. If I remember correctly, the issue was that in XML, when there is only a single element, there is nothing to differentiate array from a single property.

    In DataFlow there is a solution to this, but I do not remember there being a solution in Copy Activity back then. I will need to check whether there is now. As of April 2021 it was recommended to use DataFlow instead.

    The DataFlow solution:
    To read single xml element as array, you need to import the source projection with a sample file with multiple elements, then it can read it as array. When there is only 1 element, it gets imported as struct.


Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.