如何验证给定节点是否存在并从azure数据工厂读取值

问题描述 投票:0回答:1

我有一个查找,我正在执行查询以获取

employee_no

SELECT employee_no FROM HRS.EMPLOYEE_MASTER WHERE SOC_SEC_NO = '@{variables('FE_SoSecNo')}'
这可能会返回如下数据

{
    "firstRow": {
        "EMPLOYEE_NO": "12345"
    },
    "effectiveIntegrationRuntime": "VMSHIntegrationRuntime",
    "billingReference": {
        "activityType": "PipelineActivity",
        "billableDuration": [
            {
                "meterType": "SelfhostedIR",
                "duration": 0.016666666666666666,
                "unit": "Hours"
            }
        ],
        "totalBillableDuration": [
            {
                "meterType": "SelfhostedIR",
                "duration": 0.016666666666666666,
                "unit": "Hours"
            }
        ]
    },
    "durationInQueue": {
        "integrationRuntimeQueue": 3
    }
}

或者如果没有找到数据

{
    "effectiveIntegrationRuntime": "VMSHIntegrationRuntime",
    "billingReference": {
        "activityType": "PipelineActivity",
        "billableDuration": [
            {
                "meterType": "SelfhostedIR",
                "duration": 0.016666666666666666,
                "unit": "Hours"
            }
        ],
        "totalBillableDuration": [
            {
                "meterType": "SelfhostedIR",
                "duration": 0.016666666666666666,
                "unit": "Hours"
            }
        ]
    },
    "durationInQueue": {
        "integrationRuntimeQueue": 3
    }
}

我添加了一个步骤来读取值,如下所示,但是当 json 节点不存在时,如果节点值不存在,我尝试插入什么并通过获取值进行更新

activity('GetEmpBySSN').output.firstRow.employee_no

我可以知道如何编写读取值的逻辑吗

oracle azure-data-factory oracle-adf
1个回答
0
投票

我创建了一个布尔变量来检查查找的响应是否包含

firstrow
节点,我用来检查属性是否存在的表达式是 this

@bool(contains(activity('Lookup1').output, 'firstRow'))

我的布尔变量: enter image description here

设置变量: enter image description here

输出:

  • 查找输出不存在第一行节点: enter image description here
  • 由于第一行节点不存在,变量返回 false: enter image description here

然后,您可以在 If 活动中使用该布尔变量,以根据变量的值有条件地获取节点的值(如果它存在)。

© www.soinside.com 2019 - 2024. All rights reserved.