Azure 数据工厂:如何将一个文件夹的所有文件合并到一个文件中

azure data factory: how to merge all files of a folder into one file

我需要创建一个大文件,通过合并分散在 Azure Blob 存储中包含的几个子文件夹中的多个文件,还需要进行转换,每个文件包含一个 JSON 数组的单个元素,因此最终文件将包含 JSON 个元素的数组。

最终目的是在 Hadoop 和 MapReduce 作业中处理该大文件。

原始文件的布局与此类似:

folder
 - month-01
   - day-01
        - files...

- month-02
    - day-02
        - files...

我根据你的描述做了测试,请按照我的步骤进行。

我的模拟数据:

test1.json 驻留在文件夹中:date/day1

test2.json 驻留在文件夹中:date/day2

Source DataSet,将文件格式设置为Array of Objects,文件路径设置为root path

Sink DataSet,将文件格式设置为Array of Objects,文件路径设置为您要存储最终数据的文件。

创建 Copy Activity 并将 Copy behavior 设置为 Merge Files

执行结果:

我测试的目标仍然是Azure Blob Storage,你可以参考这个link了解Hadoop支持Azure Blob Storage