简体   繁体   English

Azure 数据工厂 - API 提取和新列

[英]Azure Data Factory - API extraction and New column

I need to extract data from an API to Azure and the API output is like this:我需要从 API 中提取数据到 Azure,API 输出是这样的:

[{"ID":0,"SourceIndex":437,"ValueName":""},
{"ID":1,"SourceIndex":438,"ValueName":"CPSA21"},
{"ID":2,"SourceIndex":439,"ValueName":"CPSA21"},
{"ID":3,"SourceIndex":440,"ValueName":"MLPDS5"},
{"ID":4,"SourceIndex":441,"ValueName":"LEOD40"},
{"ID":5,"SourceIndex":442,"ValueName":"MCN312"}]
[1234567,
[531,65,0,12,19,3]

The goal is to create a new object named "Value" with the values found in the last line of the output and write to a file.目标是使用在输出的最后一行中找到的值创建一个名为“Value”的新对象并写入文件。 Expected output:预期输出:

ID ID SourceIndex来源索引 ValueName值名称 Value价值
0 0 437 437 531 531
1 1 438 438 CPSA21 CPSA21 65 65
2 2 439 439 CPSA21 CPSA21 0 0
3 3 440 440 MLPDS5 MLPDS5 12 12
4 4 441 441 LEOD40 LEOD40 19 19
5 5 442 442 MCN312 MCN312 3 3

Is this possible to achieve using Azure Data Factory and how?这是否可以使用 Azure 数据工厂实现以及如何实现? Or would another solution be better?或者其他解决方案会更好吗? Thanks谢谢

Here is a demo that i built for your use-case.这是我为您的用例构建的演示。

First i created a Json file containing your data like so:首先,我创建了一个包含您的数据的 Json 文件,如下所示: 在此处输入图像描述

The main idea is to join the array with the Json data and add a new key as you requested, this can be done by adding a derived column.主要思想是将数组与 Json 数据连接起来,并根据您的要求添加新键,这可以通过添加派生列来完成。

ADF:自动进稿器:

  1. created a dataflow.创建了一个数据流。
  2. set a parameter in dataflow constantValues : [531,65,0,12,19,3]在数据流constantValues中设置参数:[531,65,0,12,19,3]
  3. in derived column added the value column with the corresponding value : $constantValues[ID + 1] (the idea is to match id = 0 with the first value in the array).在派生列中添加了具有相应值的值列: $constantValues[ID + 1] (想法是将 id = 0 与数组中的第一个值匹配)。
  4. saved to cached sink.保存到缓存接收器。

Parameter in pipeline:管道中的参数: 在此处输入图像描述

Derived Column:派生列: 在此处输入图像描述

Output:输出: 在此处输入图像描述

Please check this link: https://docs.microsoft.com/en-us/azure/data-factory/data-flow-derived-column请检查此链接: https ://docs.microsoft.com/en-us/azure/data-factory/data-flow-derived-column

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

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