简体   繁体   中英

Using stringify activity in azure data factory

I need to sync a cosmosdb container to sql database. The objects in cosmosdb are like so:

[
   {
      id: "d8ab4619-eb3d-4e25-8663-925bd33b9b1e",
      buyerIds: [
         "4a7c169f-0642-42a9-b5a7-214a646d6c59",
         "87a956b3-2aef-43a1-a0f0-29c07519dfbc",
         ...
      ]
   },
   {...}
]

On the SQL side, the sink table contains 2 columns: Id and BuyerId . What I want is to convert the buyerIds array to a string joined by coma for instance, to then be able to pass it to a SQL stored procedure. The sql stored procedure will then split the string, and insert as many lines in the table as there are buyerIds.

In azure adf, I tried using a stringify activity in a dataflow but I have this error and don't understand what I need to change: Stringify expressions must be a complex type or an array of complex types.

My stringify activity take the buyerIds column in input and perform the following to create the string:

reduce(buyerIds, '', #acc + ',' + #item, #result)

在此处输入图像描述

Do you know what I am missing or another way to do it more simply?

Because your property is an array, you'll want to use Flatten. That will allow you to unroll your array for the target relational destination. Use stringify to turn structures into strings.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM