映射数据流中的 Union 转换Union transformation in mapping data flow

适用于: Azure 数据工厂 Azure Synapse Analytics

Union 会将多个数据流组合成一个数据流,而这些流的 SQL Union 会作为 Union 转换的新输出。Union will combine multiple data streams into one, with the SQL Union of those streams as the new output from the Union transformation. 每个输入流中的所有架构都会合并到数据流中,不需要有联接键。All of the schema from each input stream will be combined inside of your data flow, without needing to have a join key.

通过选择每个已配置的行旁边的“+”图标,你可以在设置表中对 n 个流进行组合,包括源数据以及数据流中现有转换的流。You can combine n-number of streams in the settings table by selecting the "+" icon next to each configured row, including both source data as well as streams from existing transformations in your data flow.

联合转换Union transformation

在这种情况下,可以将来自多个源(在本例中为三个不同的源文件)的不同元数据组合在一起,将它们组合成单个流:In this case, you can combine disparate metadata from multiple sources (in this example, three different source files) and combine them into a single stream:

Union 转换概述Union transformation overview

若要实现此目的,请在“Union 设置”中通过包括要添加的所有源来添加更多行。To achieve this, add additional rows in the Union Settings by including all source you wish to add. 无需使用常见的查找或联接键:There is no need for a common lookup or join key:

Union 转换设置Union transformation settings

如果在 Union 后设置了 Select 转换,则可以重命名重叠字段或未从无标题源命名的字段。If you set a Select transformation after your Union, you will be able to rename overlapping fields or fields that were not named from headerless sources. 单击“检查”以查看本例中来自三个不同源的总共包含 132 个列的组合元数据:Click on "Inspect" to see the combine metadata with 132 total columns in this example from three different sources:

Union 转换最终结果Union transformation final

名称和位置Name and position

选择“按名称联合”时,每个列值都将从每个源放入相应的列中,并采用新的串联后的元数据架构。When you choose "union by name", each column value will drop into the corresponding column from each source, with a new concatenated metadata schema.

如果选择“按位置联合”,则每个列值都将从每个相应的源放入原始位置,从而生成一个新的组合数据流,其中,来自每个源的数据将添加到同一个流中:If you choose "union by position", each column value will drop into the original position from each corresponding source, resulting in a new combined stream of data where the data from each source is added to the same stream:

Union 输出Union output

后续步骤Next steps

探究类似的转换,包括 JoinExistsExplore similar transformations including Join and Exists.