You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@avro.apache.org by "Alexander Hasha (JIRA)" <ji...@apache.org> on 2017/01/23 04:15:27 UTC
[jira] [Created] (AVRO-1986) SchemaFromJSONData does not invert
to_json method
Alexander Hasha created AVRO-1986:
-------------------------------------
Summary: SchemaFromJSONData does not invert to_json method
Key: AVRO-1986
URL: https://issues.apache.org/jira/browse/AVRO-1986
Project: Avro
Issue Type: Bug
Components: python
Affects Versions: 1.8.1
Reporter: Alexander Hasha
Priority: Minor
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}.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)