【问题标题】:JSON file to Redshift using JSONPATHS file - Invalid jsonpath format使用 JSONPATHS 文件到 Redshift 的 JSON 文件 - 无效的 jsonpath 格式
【发布时间】:2020-03-18 18:38:10
【问题描述】:

尝试使用带有 JSONPATHS 文件的 Copy 将 JSON 文件从 s3 加载到 Redshift。该文件包含 N 条记录。

一次性加载整个集合会引发错误:

无效操作:无效的 JSONPath 格式。支持的符号是 'dot-notation' 和 'bracket-notation'

Json 路径:

{"jsonpaths":
[
    "$.item[:].col1",
    "$.item[:].col2",
    "$.item[:].col3"
]
}

示例文件:

{"item":
[
  {
    "col1":"A",
    "col2":"b",
    "col3":"d"
  },
  {
    "col1": "123",
    "col2": "red",
    "col3": "456"
  }
]
}

工作文件:-

 {"jsonpaths":
[
    "$.item[0].col1",
    "$.item[0].col2",
    "$.item[0].col3"
]
}

我做错了什么导致这个错误?

【问题讨论】:

    标签: json amazon-redshift


    【解决方案1】:

    根据documentation,有两种指定 JSONPath 的方法。一种是使用点记法,另一种是使用括号记法。

    在此示例中,用户使用点表示法,但数组已使用冒号 (:) 进行索引。索引 JSON 数组元素的正确方法是使用数字。因此 JSONPath 文件的第二个示例有效。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2016-07-11
      • 2018-08-11
      • 2016-10-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多