Azure 数据工厂中正在处理的变量的动态列表

发布于 2025-01-13 01:25:07 字数 725 浏览 3 评论 0原文

我有一个查找配置表,用于存储 1) 源表和 2) 要处理的变量列表,例如:

SQL 查找表

tableAvariableX、 variableY,variableZ <-- tableA 不止这3个变量,即还有其他变量如variableV、变量W但不需要处理

tableBvariableA,variableB <-- tableB 不止这两个变量

因此,我需要动态连接到每个表并处理每个表中的特定变量。处理步骤是将儒略日期(整数格式)转换为标准日期(日期格式)。 SQL 查询示例:

select dateadd(dd, (variableX - ((variableX/1000) * 1000)) - 1, dateadd(yy, variableX/1000, 0)) FROM [dbo].[tableA]

问题是在 ADF 中设置 lookupforEach 后,我不确定如何循环遍历变量数组(或字符串,因为 SQL DB 不允许我存储数组结果)并将所有这些变量转换为标准时间格式。

返回结果应该是要导出到接收器的处理后的数据集。

因此想检查一下在 ADF 中实现这一目标的最佳方法是什么?

谢谢你!

I have a lookup config table that stores the 1) source table and 2) list of variables to process, for example:

SQL Lookup Table:

tableA, variableX,variableY,variableZ <-- tableA has more than these 3 variables, i.e it has other variables such as variableV, variable W but they do not need to be processed

tableB, variableA,variableB <-- tableB has more than these 2 variables

Hence, I will need to dynamically connect to each table and process the specific variables in each table. The processing step is to convert the julian date (in integer format) to standard date (date format). Example of SQL query:

select dateadd(dd, (variableX - ((variableX/1000) * 1000)) - 1, dateadd(yy, variableX/1000, 0)) FROM [dbo].[tableA]

The problem is after setting up lookup and forEach in ADF, I am unsure how to loop through the variable array (or string, since SQL DB does not allow me to store array results) and convert all these variables into the standard time format.

The return result should be a processed dataset to be exported to a sink.

Hence would like to check what will be the best way to achieve this in ADF?

Thank you!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

猫腻 2025-01-20 01:25:07

我在当地环境中重现过。请参阅以下步骤。

  1. 使用查找活动,首先从控制表中获取所有表列表。

输入图片此处描述

  1. 将查找输出传递给 ForEach 活动。

输入图片这里的描述

  1. 在 ForEach 活动中,添加查找活动以从控制表中获取变量列表,其中表名称是 ForEach 活动中的当前项目。

     @concat('从 control_tb 选择 table_variables,其中 table_name = ''',item().table_name,'''')
    

输入图片此处描述

  1. 使用设置变量活动将 Lookup2 活动输出值转换为数组。

@split(activity('Lookup2').output.firstRow.table_variables,',')

在此处输入图像描述

  1. 创建另一个具有 2 个参数的管道 (pipeline2)(表名称(字符串)和变量(数组))并在 pipeline2 中添加 ForEach 活动

在此处输入图像描述

  1. 将数组参数传递给 pipeline2 中的 ForEach 活动,并使用复制活动将数据从源复制到接收器

在此处输入图像描述

  1. 将执行管道活动连接到 ForEach 活动内的管道 1。

输入图片此处描述

I have reproed in my local environment. Please see the below steps.

  1. Using lookup activity, first get all the tables list from control table.

enter image description here

  1. Pass the lookup output to ForEach activity.

enter image description here

  1. Inside ForEach activity, add lookup activity to get the variables list from control table where table name is current item from ForEach activity.

      @concat('select table_variables from control_tb where table_name = ''',item().table_name,'''')
    

enter image description here

  1. Convert lookup2 activity output value to an array using set variable activity.

@split(activity('Lookup2').output.firstRow.table_variables,',')

enter image description here

  1. create another pipeline (pipeline2) with 2 parameters (table name (string) and variables (array)) and add ForEach activity in pipeline2

enter image description here

  1. Pass the array parameter to ForEach activity in pipeline2 and Use the copy activity to copy data from source to sink

enter image description here

  1. Connect Execute pipeline activity to pipeline 1 inside ForEach activity.

enter image description here

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文