Starry Wisdom

Entropic Words from Neilathotep

Thursday, December 20, 2018

A quick word on avro schema definition

Avro vexes me every time I use it – and the documentation is helpfully only to a small extent.  Today I was trying to add a field that stored a list (array) of strings and had a default value to an already existing schema. I tried a couple of things…

#doesn't work
{"name": "foo", {"type": "array", "items": "string"}, "default": ["bar"]}

#doesn't work
{"name": "foo", "type": {"type": "array", "items": "string"}, "default": ["bar"]}

Before I realized that the “type” required a list of types in this case, even if the list was one element long. So this is the working pattern:

{"name": "foo", "type": [{"type": "array", "items": "string"}], "default": ["bar"]}
posted by neil at 10:27 pm
under Uncategorized  

Powered by WordPress