首页 > 解决方案 > 数据融合无法解析来自 JSON 的响应

问题描述

我正在使用 CDAP 参考来启动数据融合批处理管道(GCS 到 GCS)。

curl -w "\n" -X POST -H "Authorization: Bearer ${AUTH_TOKEN}" \
"${CDAP_ENDPOINT}/v3/namespaces/default/apps/${PIPELINE_NAME}/workflows/DataPipelineWorkflow/start" \
-d "{ argfile : '${ARGUMENT_FILE}' }"  

其中 argfile 是参数设置器宏的输入 URL

参数 json 文件是:

{

  "arguments": [

    {

      "name": "input.path",

      "type": "string",

      "value": "gs://bucket/employee_sample.csv"

    },

    {

      "name": "directive",

      "type": "array",

      "value": [

        "parse-as-csv :body ',' true",

        "drop body"

      ]

    },

    {

      "name": "output.path",

      "type": "string",

      "value": "gs://bucket/FusionOutput"

    },

    {

      "name": "PROJECT_ID",

      "type": "string",

      "value": "project-id"

    },

    {

      "name": "output.schema",

      "type": "schema",

      "value": [

        {

          "name": "emp_id",

          "type": "string",

          "nullable": true

        },

        {

          "name": "name_prefix",

          "type": "string",

          "nullable": true

        },

        {

          "name": "first_name",

          "type": "string",

          "nullable": true

        }

      ]

    }

  ]

}

这里的问题是我收到了这个错误

Pipeline 'gcs_fusion' failed.
io.cdap.cdap.api.macro.InvalidMacroException: Argument 'input.path' is not defined.
    at io.cdap.cdap.etl.common.DefaultMacroEvaluator.lookup(DefaultMacroEvaluator.java:54) ~[na:na]
    at io.cdap.cdap.internal.app.runtime.plugin.MacroParser.findRightmostMacro(MacroParser.java:144)

java.lang.RuntimeException: Could not parse response from 'https://storage.cloud.google.com/bucket/argumentj.json': java.lang.IllegalStateException: Expected BEGIN_OBJECT but was STRING at line 2 column 1
    at io.cdap.plugin.ArgumentSetter.handleResponse(ArgumentSetter.java:83) ~[na:na]
    at io.cdap.plugin.http.HTTPArgumentSetter.run(HTTPArgumentSetter.java:76) ~[na:na]

当我尝试通过 Data Fusion UI 控制台传递参数设置器 URL 时,相同的管道在某些运行中使用相同的模板。

参数设置器 JSON 遵循https://github.com/data-integrations/argument-setter中规定的语法,并且参数 json 文件在存储桶中设置为公共。

如果有人能解决这个问题会很有帮助。

请注意,我在这里匿名化了我的项目详细信息

标签: google-cloud-platformgoogle-cloud-data-fusion

解决方案


假设您的存储桶可公开访问,那么您要提供给参数设置器的 URL 具有以下模式:

https://storage.googleapis.com/[BUCKET_NAME]/[OBJECT_NAME]

如果存储桶不可公开访问,您将需要为 Google Cloud Storage 中的参数文件生成签名 URL。您可以在此处阅读有关如何生成签名 URL 的更多信息。


推荐阅读