Details
-
Bug
-
Status: Open
-
Minor
-
Resolution: Unresolved
-
1.8.1
-
None
-
None
Description
A record schema containing a fixed field causes an error when trying to invert `to_json` with `SchemaFromJSONData`.
To reproduce, using avro-python3==1.8.1 and python 3.6.0
>>> test_schema_str = """ ... { ... "type" : "record", ... "namespace" : "dataset", ... "name" : "test_dataset", ... "fields": [ ... {"type": "int" , "name": "field_1"}, ... {"type": "string", "name": "field_2"}, ... {"default": null, "name": "field_3", "type": ["null", "long"]}, ... { "name": "features", "type": { "type": "map", "values": "double"}}, ... { "name": "words", "type": {"type": "array", "items": "string"}}, ... { "name": "bytes", "type": {"type": "fixed", "name": "Bytes", "size": 16}} ... ] ... } ... """ >>> from avro.schema import SchemaFromJSONData >>> from avro.schema import Parse >>> SchemaFromJSONData(Parse(test_schema_str).to_json()) Traceback (most recent call last): File "<stdin>", line 1, in <module> File "<redacted>/python3.6/site-packages/avro/schema.py", line 1254, in SchemaFromJSONData return parser(json_data, names=names) File "<redacted>/python3.6/site-packages/avro/schema.py", line 1182, in _SchemaFromJSONObject other_props=other_props, File "<redacted>/python3.6/site-packages/avro/schema.py", line 1061, in __init__ fields = make_fields(names=nested_names) File "<redacted>/python3.6/site-packages/avro/schema.py", line 1173, in MakeFields return tuple(RecordSchema._MakeFieldList(field_desc_list, names)) File "<redacted>/site-packages/avro/schema.py", line 986, in _MakeFieldList yield RecordSchema._MakeField(index, field_desc, names) File "<redacted>/python3.6/site-packages/avro/schema.py", line 957, in _MakeField names=names, File "<redacted>/python3.6/site-packages/avro/schema.py", line 1253, in SchemaFromJSONData 'Invalid JSON descriptor for an Avro schema: %r.' % json_data) avro.schema.SchemaParseException: Invalid JSON descriptor for an Avro schema: {'type': 'fixed', 'name': 'Bytes', 'namespace': 'dataset', 'size': 16}.