Azure Data Factory (ADF) 中的变量自减操作
在 ADF(Azure Data Factory)管道中,变量的自减操作可以通过以下步骤实现:
- 创建一个变量,并设置初始值。
- 使用'Set Variable'活动来获取变量的当前值。
- 使用'Expression'选项将变量值减1。 例如:@sub(variables('myVariable'), 1)
- 使用'Set Variable'活动将新的值设置回变量中。
以下是一个示例 ADF 管道中的 JSON 配置示例:
{
"name": "MyPipeline",
"properties": {
"activities": [
{
"name": "GetVariableValue",
"type": "GetVariable",
"typeProperties": {
"variableName": "myVariable"
}
},
{
"name": "DecrementVariable",
"type": "SetVariable",
"typeProperties": {
"variableName": "myVariable",
"value": {
"value": "@sub(variables('myVariable'), 1)",
"type": "Expression"
}
}
}
],
"variables": {
"myVariable": {
"type": "Int",
"defaultValue": 10
}
},
"annotations": []
}
}
在以上示例中,首先使用'GetVariable'活动来获取变量的当前值,然后使用'SetVariable'活动将新的值设置回变量中,并通过表达式@sub(variables('myVariable'), 1)将变量的值减1。
原文地址: https://www.cveoy.top/t/topic/qmZf 著作权归作者所有。请勿转载和采集!