【问题标题】:AVRO schema's JSON looks valid but returns Input is not a valid Avro schemaAVRO 模式的 JSON 看起来有效,但返回 Input is not a valid Avro 模式
【发布时间】:2019-11-11 16:12:17
【问题描述】:

我正在尝试将数据上传到 AWS Personalize 中的用户数据集。该架构包含我的 CSV 的结构。我在网上检查了它的 JSON,它显示了有效的 JSON。

{
    "type": "record",
    "name": "Users",
    "namespace": "com.amazonaws.personalize.schema",
    "fields": [
        {
            "name": "user_id",
            "type": "string"
        },
        {
            "name": "address",
            "type": "record",
            "fields" : [
                {"name": "address1", "type": "string"},
                {"name": "address2", "type": "string"},
                {"name": "city", "type": "string"},
                {"name": "state", "type": "string"},
                {"name": "postalCode", "type": "int"},
                {"name": "coordinates", "type": "record",
                "fields" : [
                    {"name": "lat", "type": "float"},
                    {"name": "lng", "type": "float"}
                    ]}
                    ]
        },
        {
            "name": "firstName",
            "type": "string"
        },
        {
            "name": "followRequestId",
            "type": "array",
            "items": "string"
        },
        {
            "name": "followers",
            "type": "array",
            "items": "string"
        },
        {
            "name": "fullName",
            "type": "string"
        },
        {
            "name": "gender",
            "type": "string"
        },
        {
            "name": "interests",
            "type": "array",
            "items": "string"
        },
        {
            "name": "lastActive",
            "type": "long"
        },
        {
            "name": "lastName",
            "type": "string"
        },
        {
            "name": "network",
            "type": "list"
        },
        {
            "name": "paymentDetails",
            "type": "int"
        },
        {
            "name": "personalOccasions",
            "type": "array",
            "items": "string"
        },
        {
            "name": "productLikeDislike",
            "type": "array",
            "items": "string"
        },
        {
            "name": "registrationDate",
            "type": "long"
        },
        {
            "name": "rewardId",
            "type": "string"
        },
        {
            "name": "wishList",
            "type": "array",
            "items": "string"
        }
    ],
    "version": "1.0"
}

【问题讨论】:

  • 还有什么方法可以添加示例 csv 文件。这看起来像一个复杂的数据集,我希望看到样本 csv 有 1-2 行。特别想看数组和记录。

标签: amazon-web-services avro amazon-personalize


【解决方案1】:

您没有正确写入记录字段。

例子:

...
{
"name":"address1",
"type":{
     "type":"record",
     "name": "address",
     "fields": [...]
  }
}
...

因此,当您将记录写为字段时,首先您有字段名称,然后是“通用”记录(类似于类的方式:address1 是变量,address 是类)。

【讨论】:

    猜你喜欢
    • 2018-04-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-08-09
    • 1970-01-01
    • 2018-04-17
    • 1970-01-01
    相关资源
    最近更新 更多