Gabriel Andersson created AVRO-2363:
---------------------------------------
Summary: avro.schema.Schema in py3 prevents same record type from
being used multiple times in same schema
Key: AVRO-2363
URL: https://issues.apache.org/jira/browse/AVRO-2363
Project: Apache Avro
Issue Type: Bug
Components: python
Affects Versions: 1.9.0
Reporter: Gabriel Andersson
After mostly worked in Java with avro, schemas have been used in an hierachial
way. I.e. Schema A imports Schema B and Schema C, Schema B imports schema C.
This works in a confluent setting. But when loading the schema, the application
crashes due to reusing record types.
The following relaxes this relation.
avro.schema.py
{code:java}
diff --git a/lang/py3/avro/schema.py b/lang/py3/avro/schema.py
index 7ce29731..63af3581 100644
--- a/lang/py3/avro/schema.py
+++ b/lang/py3/avro/schema.py
@@ -397,9 +397,6 @@ class Names(object):
if schema.fullname in VALID_TYPES:
raise SchemaParseException(
'%s is a reserved type name.' % schema.fullname)
- if schema.fullname in self.names:
- raise SchemaParseException(
- 'Avro name %r already exists.' % schema.fullname)
logger.log(DEBUG_VERBOSE, 'Register new name for %r', schema.fullname)
self._names[schema.fullname] = schema
{code}
Example schema:
{code:java}
{
"doc": "",
"fields": [
{
"default": null,
"doc": "Optional. The context used for tracing of flow.",
"name": "b",
"type": [
"null",
{
"doc": "",
"fields": [
{
"doc": "",
"name": "c",
"type": {
"doc": "",
"fields": [
{
"doc": "",
"name": "value",
"type": "string"
}
],
"name": "C",
"type": "record"
}
}
],
"name": "B",
"type": "record"
}
]
},
{
"doc": "",
"name": "c",
"type": {
"doc": "",
"fields": [
{
"doc": "",
"name": "value",
"type": "string"
}
],
"name": "C",
"type": "record"
}
}
],
"name": "A",
"namespace": "namespace",
"type": "record"
}
{code}
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)