如何在 Azure 数据工厂中验证列名和列顺序

How to validate Column Names and Column Order in Azure Data Factory

我想从存储在 Azure 文件中的文件中读取列名,然后验证列名和序列,例如"First_Column"="First_Column", "Second_Column"= "Second_Column", ...等等,顺序也应该匹配。请建议在 Azure 数据工厂中执行此操作的方法。

更新:

  1. 或者我们可以使用Lookupactivity来查看header,但是判断条件会稍微复杂一些。

  2. 在 If Condition1 中,我们可以使用表达式:@and(and(equals(activity('Lookup1').output.firstRow.Prop_0,'First_Column'),equals(activity('Lookup1').output.firstRow.Prop_1,'Second_Column')),equals(activity('Lookup1').output.firstRow.Prop_2,'Third_Column'))


我们可以通过column patterns in derived column验证数据流中的列名和序列。
例如:
源数据csv文件是这样的:

  1. 数据流是这样的: 我没有 select 第一行 header ,所以我们可以将 csv 文件的 header 读入数据流。

  2. 然后我用SurrogateKey1给数据加上一个row_no

数据预览是这样的:

  1. 在 ConditionalSplit1 activity,我使用 row_no == 1 过滤 headers。

  2. 在 DerivedColumn1 activity,我使用多个列模式来验证列名和序列。
    结果如下: