You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

ADF中如何在Foreach内通过Execute Pipeline传递列名与脚本输出至子管道

Azure Data Factory 两个需求的解决方案

首先明确你提供的脚本活动输出结构:

{
    "resultSetCount": 1,
    "recordsAffected": 21,
    "resultSets": [
        {
            "rowCount": 21,
            "rows": [
                {
                    "name": "EMPID",
                    "type": "NUMBER(12,0)",
                    "kind": "COLUMN",
                    "null?": "Y",
                    "default": null,
                    "primary key": "N",
                    "unique key": "N",
                    "check": null,
                    "expression": null,
                    "comment": "T",
                    "policy name": null,
                    "privacy domain": null
                },
                {
                    "name": "NAME",
                    "type": "VARCHAR(16777216)",
                    "kind": "COLUMN",
                    "null?": "Y",
                    "default": null,
                    "primary key": "N",
                    "unique key": "N",
                    "check": null,
                    "expression": null,
                    "comment": "The name of the tablespace this record comes from",
                    "policy name": null,
                    "privacy domain": null
                }
            ]
        }
    ]
}

需求1:Foreach活动内通过Execute Pipeline传递父管道列名给子管道

按以下步骤配置:

  • 子管道侧:在子管道的「参数」页面新建参数,命名为TargetColumnName,类型选择「字符串」。
  • 父管道侧:
    1. 配置Foreach活动的「迭代项」为脚本输出的行数据,表达式写:@activity('你的脚本活动名称').output.resultSets[0].rows
    2. 在Foreach内部添加Execute Pipeline活动,选择你要调用的子管道。
    3. 切换到Execute Pipeline的「参数」标签,找到子管道的TargetColumnName参数,赋值为@item().name(这里的name对应脚本输出中存储列名的字段)。
  • 子管道内使用:在子管道的任意活动中,用@pipeline().parameters.TargetColumnName就能获取传递过来的列名。

需求2:将脚本活动的输出传递给Execute Pipeline供子管道使用

分两种场景处理:

场景1:传递脚本活动的完整输出

  • 子管道侧:新建参数ScriptFullOutput,类型选择「对象」。
  • 父管道侧:在Execute Pipeline的参数配置中,给ScriptFullOutput赋值为@activity('你的脚本活动名称').output。
  • 子管道内引用示例:
    • 获取结果集数量:@pipeline().parameters.ScriptFullOutput.resultSetCount
    • 获取第一行的列名:@pipeline().parameters.ScriptFullOutput.resultSets[0].rows[0].name

场景2:仅传递脚本输出的列数据集(rows数组)

  • 子管道侧:新建参数ColumnRows,类型选择「数组」。
  • 父管道侧:赋值为@activity('你的脚本活动名称').output.resultSets[0].rows。
  • 子管道内使用:比如在子管道的Foreach活动中,设置迭代项为@pipeline().parameters.ColumnRows,然后用@item().name获取列名,@item().type获取列数据类型。

内容的提问来源于stack exchange,提问作者Vamshi Reddy

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.30 16:25:26