添加设置变量活动时 Azure Synapse Pipeline 出现错误请求

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

我有一个简单的 Synapse 管道来查询 SQL 数据库。查询按预期工作,但是当我尝试添加“设置变量”活动来输出结果时,出现以下错误:

{ "code": "BadRequest",
  "message": null,
  "target": "pipeline//runid/<runID goes here>",
  "details": null,
  "error": null
}

我的突触管道只有两个活动:脚本和设置变量:

{
"name": "query_resource",
"properties": {
  "activities": [
      {
          "name": "Test query",
          "type": "Script",
          "dependsOn": [],
          "policy": {
              "timeout": "0.12:00:00",
              "retry": 0,
              "retryIntervalInSeconds": 30,
              "secureOutput": false,
              "secureInput": false
          },
          "linkedServiceName": {
              "referenceName": "***************",
              "type": "LinkedServiceReference"
          },
          "typeProperties": {
              "scripts": [
                  {
                      "type": "Query",
                      "text": {
                          "value": "@pipeline().parameters.query",
                          "type": "Expression"
                      }
                  }
              ],
              "scriptBlockExecutionTimeout": "02:00:00"
          }
      },
      {
          "name": "Query Result",
          "type": "SetVariable",
          "dependsOn": [
              {
                  "activity": "Test query",
                  "dependencyConditions": [
                      "Succeeded"
                  ]
              }
          ],
          "policy": {
              "secureOutput": false,
              "secureInput": false
          },
          "userProperties": [],
          "typeProperties": {
              "variableName": "pipelineReturnValue",
              "value": [
                  {
                      "key": "queryResult",
                      "value": {
                          "type": "Object",
                          "content": "@activity('Test query').output.resultSets"
                      }
                  }
              ],
              "setSystemVariable": true
          }
      }
  ],
  "parameters": {
      "query": {
          "type": "string",
          "defaultValue": "SELECT * FROM OPENQUERY(*********, 'SELECT Some query that is successful')"
      }
  },
  "annotations": [],
  "lastPublishTime": "2024-10-25T22:05:38Z"
},
"type": "Microsoft.Synapse/workspaces/pipelines"
}

我希望管道成功运行并且查询结果存储在变量中。

pipeline azure-synapse bad-request
1个回答
0
投票

当使用“设置变量类型”为

String
并将变量值设置为“
@activity('Script1').output.resultSets
”时,我遇到了与您相同的错误:

enter image description here

这是正确的管道

JSON
,它使用创建为
String
的变量对我有用:

enter image description here

{
    "name": "Pipeline 1",
    "properties": {
        "activities": [
            {
                "name": "Script1",
                "type": "Script",
                "dependsOn": [],
                "policy": {
                    "timeout": "12:00:00",
                    "retry": 0,
                    "retryIntervalInSeconds": 30,
                    "secureOutput": false,
                    "secureInput": false
                },
                "userProperties": [],
                "linkedServiceName": {
                    "referenceName": "AzureSqlDatabase1",
                    "type": "LinkedServiceReference"
                },
                "typeProperties": {
                    "scripts": [
                        {
                            "type": "Query",
                            "text": "SELECT TOP 1 FileName FROM filestatus\n"
                        }
                    ],
                    "scriptBlockExecutionTimeout": "02:00:00"
                }
            },
            {
                "name": "Set variable1",
                "type": "SetVariable",
                "dependsOn": [
                    {
                        "activity": "Script1",
                        "dependencyConditions": [
                            "Succeeded"
                        ]
                    }
                ],
                "policy": {
                    "secureOutput": false,
                    "secureInput": false
                },
                "userProperties": [],
                "typeProperties": {
                    "variableName": "QueryResult",
                    "value": {
                        "value": "@activity('Script1').output.resultSets[0].rows[0].FileName",
                        "type": "Expression"
                    }
                }
            }
        ],
        "variables": {
            "QueryResult": {
                "type": "String"
            }
        },
        "annotations": []
    }
}

enter image description here

enter image description here

在上面的管道中,我使用了

String
的“设置变量”活动的值,如下所示:
@activity('Script1').output.resultSets[0].rows[0].FileName

结果:

enter image description here

第二种方法:您可以将“设置变量类型”设置为

ARRAY

enter image description here

然后使用“设置变量”活动的值,如下所示:

@activity('Script1').output.resultSets

结果: enter image description here

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