I would like to store two-dimensional arrays of numbers in Avro. I have tried the following:
{ "namespace": "com.company", "type": "record", "name": "MyName", "doc" : "...", "fields": [ { "name": "MyArray", "type": { "type": "array", "items": { "type": {"type": "array","items": "int"} } } } ] }
But when I tried to read it with the parser:
import avro.schema schema = avro.schema.parse(open("my_schema.avsc", "r").read())
I get the following error:
avro.errors.SchemaParseException: Type property "{'type': 'array', 'items': {'type': {'type': 'array', 'items': 'int'}}}" not a valid Avro schema: Items schema ({'type': {'type': 'array', 'items': 'int'}}) not a valid Avro schema: Undefined type: {'type': 'array', 'items': 'int'} (known names: dict_keys(['com.algoint.ecg_frame_file.EcgFrameFile']))
Advertisement
Answer
It looks like you have one too many type
keys.
You schema should be this instead:
{ "namespace": "com.company", "type": "record", "name": "MyName", "doc" : "...", "fields": [ { "name": "MyArray", "type": { "type": "array", "items": {"type": "array","items": "int"} } } ] }