I've seen many examples of Avro schema fields having unions allowing a type OR null, e.g:
{
"name": "MyMessageType",
"type": "record",
"fields": [
{
"name": "userId",
"type": [
"null",
"string"
],
"default": null,
},
{ ... more fields ... }
]
}
I've never seen an example showing multiple non-null types, e.g:
{
"name": "MyMessageType",
"type": "record",
"fields": [
{
"name": "userId",
"type": [
"null",
"string",
"int"
],
"default": null,
},
{ ... more fields ... }
]
}
The docs don't mention this either way - is it possible?
And is it recommended? Has anyone used this format before?
This is definitely supported. There is no recommendation for or against. It really just depends on the needs of your schema.