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