AVRO,将记录转换为数组

时间:2019-05-27 14:37:25

标签: apache-kafka avro

我的AVRO架构有一个fileObject记录,但是我需要将其更改为fileObject的数组。我该怎么办?

        {
            "name": "file",
            "type": ["null", {
                "type": "record",
                "name": "FileObject",
                "doc": "file object",
                "fields": [{
                        "name": "fileUrl",
                        "type": ["null", "string"],
                        "doc": "url of the file"
                    },
                    {
                        "name": "spId",
                        "type": ["null", "string"],
                        "doc": "space id"
                    },
                    {
                        "name": "contentId",
                        "type": ["null", "string"],
                        "doc": "content id of the file"
                    },
                    {
                        "name": "versionId",
                        "type": ["null", "string"],
                        "doc": "version id of the file"
                    }
                ]
            }]
        },

1 个答案:

答案 0 :(得分:0)

我让它起作用

    {
        "name": "files",
        "type": {
            "type": "array",
            "items":{
                "name": "FileObjects",
                "type": "record",
                "fields":[{
                    "name": "fileUrl",
                    "type": ["null", "string"],
                    "doc": "url of the file"
                },
                {
                    "name": "sId",
                    "type": ["null", "string"],
                    "doc": "sid of the file"
                },
                {
                    "name": "contentId",
                    "type": ["null", "string"],
                    "doc": "content id of the file"
                },
                {
                    "name": "versionId",
                    "type": ["null", "string"],
                    "doc": "version id of the file"
                }]
            }
        },
        "default": []
    }