如何使用数据流在Blob存储中获取JSON数组 [英] How to get JSON Array in a blob storage using dataflow
问题描述
我正在Data-Factory中使用Azure Dataflow.我有一个Azure SQL数据库作为源.下面是示例:
I am using Azure Dataflow in Data-Factory. I have an Azure SQL database as a source. Below is the sample:
Firstname Lastname Age phone mobile
Don Bosco 56 34578970 134643455
Abraham Lincoln 87 56789065 246643556
下面是数据流:
Source -> Sink (JSON Blob storage)
在接收器中,我得到一个文件,输出如下:
In the sink, I am getting a single file and the output is like:
{"Firstname": "Don", "Lastname": Bosco, "Age": 56, "contact": [{"number": "34578970", "type": "phone"}, {"number": "134643455", "type": "mobile"}]}
{"Firstname": "Abraham", "Lastname": Lincoln, "Age": 87, "contact": [{"number": "56789065", "type": "phone"}, {"number": "246643556", "type": "mobile"}]}
相反,我需要获得如下输出:
Instead, I need to get the output as below:
[
{"Firstname": "Don", "Lastname": Bosco, "Age": 56, "contact": [{"number": "34578970", "type": "phone"}, {"number": "134643455", "type": "mobile"}]},
{"Firstname": "Abraham", "Lastname": Lincoln, "Age": 87, "contact": [{"number": "56789065", "type": "phone"}, {"number": "246643556", "type": "mobile"}]}
]
我知道如何在复制活动中执行此操作,但找不到任何方法来处理数据流.我需要在数据流中执行此操作,因为复制数据活动不支持复杂类型,因此不支持json内的数组.请帮助解决此问题.
I know how to do this in copy activity but can't find any way to do this with dataflow. I need to do this in dataflow because copy data activity does not support complex types and so array inside json is not supported. Kindly, help solve this.
推荐答案
您必须将其输出为数组而不是struct.使用没有分组依据的聚合器,并使用以下语法收集所有行(收集功能)-收集(@(FirstName = FirstName,Lastname = LastName .....)).
You have to output this as array instead of struct. Use an aggregator with no group by and collect all the rows(collect function) with the syntax - collect(@(FirstName = FirstName, Lastname = LastName.....)).
在这里,您将获得一系列结构.您可以将其写入JSON接收器.
Here you will get an array of structures. You can write this to JSON sink.
这篇关于如何使用数据流在Blob存储中获取JSON数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!