简体   繁体   English

在 azure 数据工厂中使用 stringify 活动

[英]Using stringify activity in azure data factory

I need to sync a cosmosdb container to sql database.我需要将一个 cosmosdb 容器同步到 sql 数据库。 The objects in cosmosdb are like so: cosmosdb 中的对象是这样的:

[
   {
      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 .在 SQL 端,接收器表包含 2 列: IdBuyerId 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.我想要的是将 buyerIds 数组转换为由逗号连接的字符串,例如,然后能够将其传递给 SQL 存储过程。 The sql stored procedure will then split the string, and insert as many lines in the table as there are buyerIds.然后 sql 存储过程将拆分字符串,并在表中插入与 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.在 azure adf 中,我尝试在数据流中使用 stringify 活动,但出现此错误并且不明白我需要更改的内容: Stringify 表达式必须是复杂类型或复杂类型数组。

My stringify activity take the buyerIds column in input and perform the following to create the string:我的 stringify 活动采用输入中的 buyerIds 列并执行以下操作来创建字符串:

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.因为您的属性是一个数组,所以您需要使用 Flatten。 That will allow you to unroll your array for the target relational destination.这将允许您为目标关系目标展开数组。 Use stringify to turn structures into strings.使用 stringify 将结构转换为字符串。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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