问题
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