Kengo Seki created AVRO-2444:
--------------------------------
Summary: Fix gen_interop_data.py to work with interop.avsc
Key: AVRO-2444
URL: https://issues.apache.org/jira/browse/AVRO-2444
Project: Apache Avro
Issue Type: Bug
Components: interop, python
Reporter: Kengo Seki
Assignee: Kengo Seki
The following command fails, since the value assigned to bytesField in
gen_interop_data.py is a str, not bytes.
{code}
$ python3 lang/py3/avro/tests/gen_interop_data.py
share/test/schemas/interop.avsc /tmp/py3.avro
Traceback (most recent call last):
File "lang/py3/avro/tests/gen_interop_data.py", line 55, in <module>
dfw.append(DATUM)
File "/home/sekikn/.local/lib/python3.6/site-packages/avro/datafile.py", line
303, in append
self.datum_writer.write(datum, self.buffer_encoder)
File "/home/sekikn/.local/lib/python3.6/site-packages/avro/io.py", line 817,
in write
raise AvroTypeException(self.writer_schema, datum)
avro.io.AvroTypeException: The datum {'intField': 12, 'longField': 15234324,
'stringField': 'hey', 'boolField': True, 'floatField': 1234.0, 'doubleField':
-1234.0, 'bytesField': '12312adf', 'nullField': None, 'arrayField': [5.0, 0.0,
12.0], 'mapField': {'a': {'label': 'a'}, 'bee': {'label': 'cee'}},
'unionField': 12.0, 'enumField': 'C', 'fixedField': b'1019181716151413',
'recordField': {'label': 'blah', 'children': [{'label': 'inner', 'children':
[]}]}} is not an example of the schema {
"type": "record",
"name": "Interop",
"namespace": "org.apache.avro",
"fields": [
{
"type": "int",
"name": "intField"
},
{
"type": "long",
"name": "longField"
},
{
"type": "string",
"name": "stringField"
},
{
"type": "boolean",
"name": "boolField"
},
{
"type": "float",
"name": "floatField"
},
{
"type": "double",
"name": "doubleField"
},
{
"type": "bytes",
"name": "bytesField"
},
{
"type": "null",
"name": "nullField"
},
{
"type": {
"type": "array",
"items": "double"
},
"name": "arrayField"
},
{
"type": {
"type": "map",
"values": {
"type": "record",
"name": "Foo",
"namespace": "org.apache.avro",
"namespace": "org.apache.avro",
"fields": [
{
"type": "string",
"name": "label"
}
]
}
},
"name": "mapField"
},
{
"type": [
"boolean",
"double",
{
"type": "array",
"items": "bytes"
}
],
"name": "unionField"
},
{
"type": {
"type": "enum",
"name": "Kind",
"namespace": "org.apache.avro",
"symbols": [
"A",
"B",
"C"
]
},
"name": "enumField"
},
{
"type": {
"type": "fixed",
"name": "MD5",
"namespace": "org.apache.avro",
"size": 16
},
"name": "fixedField"
},
{
"type": {
"type": "record",
"name": "Node",
"namespace": "org.apache.avro",
"fields": [
{
"type": "string",
"name": "label"
},
{
"type": {
"type": "array",
"items": "org.apache.avro.Node"
},
"name": "children"
}
]
},
"name": "recordField"
}
]
}
{code}
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)