Compatibility of Avro contract with enum

假装没事ソ 提交于 2021-02-11 14:51:24

问题


I have an existing avro schema

{
"name": "myenum",
"type": {
        "type": "enum",
        "name": "Suit",
        "symbols": ["SPADES", "HEARTS", "DIAMONDS", "CLUBS"]
    },
"default": null
}

I want to add null to be the default and updating the contract to the following result in backward compatibility error. what can be done to solve this issue

{
"name": "myenum",
"type": [ null, {
        "type": "enum",
        "name": "Suit",
        "symbols": ["SPADES", "HEARTS", "DIAMONDS", "CLUBS"]
    }],
"default": null
}

回答1:


There is a problem with the null that is been added.

i.e.

{
    "name": "myenum",
    "type": [ null, { <- problem
        "type": "enum",
        "name": "Suit",
        "symbols": ["SPADES", "HEARTS", "DIAMONDS", "CLUBS"]
    }],
    "default": null
}

It should be within quotes: null => "null". So updated definition will be like:

{
    "name": "myenum",
    "type": [ "null", { <- change
        "type": "enum",
        "name": "Suit",
        "symbols": ["SPADES", "HEARTS", "DIAMONDS", "CLUBS"]
    }],
    "default": null
}


来源:https://stackoverflow.com/questions/65073407/compatibility-of-avro-contract-with-enum

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!