Hadoop Avro模式演变:扩展现有阵列
标准的Avro模式演化示例显示了向记录添加带有默认值的新字段。但是,如果您的旧模式有一个数组,并且您希望向该数组添加一个新字段,该怎么办 例如,给定一组记录:Hadoop Avro模式演变:扩展现有阵列,hadoop,avro,Hadoop,Avro,标准的Avro模式演化示例显示了向记录添加带有默认值的新字段。但是,如果您的旧模式有一个数组,并且您希望向该数组添加一个新字段,该怎么办 例如,给定一组记录: { "type": "array", "items": { "name": "Loss", "type": "record", "fields": [ { "name": "lossTotalAmount", "type": [ "null", "string"
{
"type": "array",
"items": {
"name": "Loss",
"type": "record",
"fields": [
{
"name": "lossTotalAmount",
"type": [ "null", "string" ],
"default": null
},
{
"name": "lossType",
"type": [ "null", "string" ],
"default": null
},
{
"name": "lossId",
"type": [ "null", "string" ],
"default": null
},
{
"name": "vehicleLossCode",
"type": [ "null", "string" ],
"default": null
}
]
}
}
添加新字段claimNumber
:
{
"type": "array",
"items": {
"name": "Loss",
"type": "record",
"fields": [
{
"name": "lossTotalAmount",
"type": [ "null", "string" ],
"default": null
},
{
"name": "lossType",
"type": [ "null", "string" ],
"default": null
},
{
"name": "lossId",
"type": [ "null", "string" ],
"default": null
},
{
"name": "vehicleLossCode",
"type": [ "null", "string" ],
"default": null
},
{
"name": "claimNumber",
"type": [ "null", "string" ],
"default": null
}
]
}
}
当我开始遇到反序列化异常时,使用常规技术似乎不起作用。是否有不同的方法来扩展Avro中现有的数组?或者是不可能的?根据Avro的进化规则,这两种模式看起来是兼容的;反序列化时是否同时显式指定读写器的模式?能否提供反序列化代码或得到的反序列化异常?