[
https://issues.apache.org/jira/browse/AVRO-2809?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17105334#comment-17105334
]
Ryan Skraba commented on AVRO-2809:
-----------------------------------
Hello! From the [spec|https://avro.apache.org/docs/1.9.2/spec.html#names]:
bq. A schema or protocol may not contain multiple definitions of a fullname.
So you can't define a new record named *roleNotesGroup* if that name already
exists.
I can suggest a workaround: we construct Avro schemas from a couple of
different hierarchical sources. As we traverse the source, we generate unique
namespaces to prevent name collisions.
> XSD to Avro Conversion - SchemaParseException: can't redefine roleNotesGroup
> ----------------------------------------------------------------------------
>
> Key: AVRO-2809
> URL: https://issues.apache.org/jira/browse/AVRO-2809
> Project: Apache Avro
> Issue Type: Bug
> Components: java
> Affects Versions: 1.9.2
> Reporter: Nikeshh Baskaran
> Priority: Blocker
>
> *I am working on converting xsd to avro schema*
>
> *XSD snippet:*
>
> {{<xsd:element
> name="*roleNotesGroup*"><xsd:complexType><xsd:sequence><xsd:element
> name="*roleNotesSubGroup*" minOccurs="0"
> maxOccurs="unbounded"><xsd:complexType><xsd:sequence><xsd:element
> name="*roleNotesGroup*" minOccurs="0"
> maxOccurs="unbounded"><xsd:complexType><xsd:sequence><xsd:element
> name="roleNotes" type="xsd:string"
> minOccurs="0"><xsd:annotation><xsd:appinfo><source application="CUSTOMER"
> field="REL.CUSTOMER"/><fieldPiiAttribute value="INDIRECT"/><fieldPiiPurpose
> value="LEGITIMATE"/><fieldPiiEraseOption
> value="NO.ACTION"/><fieldPiiAccessibility value="ACCESS
> PORTABLE"/></xsd:appinfo></xsd:annotation></xsd:element></xsd:sequence><xsd:attribute
> name="index"
> type="xsd:integer"/></xsd:complexType></xsd:element></xsd:sequence><xsd:attribute
> name="index"
> type="xsd:integer"/></xsd:complexType></xsd:element></xsd:sequence><xsd:attribute
> name="index" type="xsd:integer"/></xsd:complexType></xsd:element>}}
> I am using
> *{{Schema schema = Schema.createRecord(name, null, null, false);}}*
> to create a avro schema record. In the above xsd roleNotesGroup is a child
> of roleNotesSubGroup which is a child of roleNotesGroup. I can recursively
> obtain the avro schema till roleNotesSubGroup which is then converted to list.
>
> *{{List<Schema.Field> is obtained recursively.}}*
> Now the problem is when i try to add the Fields formed to the head element
> roleNotesGroup using
>
> {{*Schema schema = Schema.createRecord(name, null, null, false);*}}
> {{*schema.setFields(schemaFields**);*}}
> *I get the following error : SchemaParseException: can't redefine
> roleNotesGroup*
>
> *Is there any restriction in avro or avro conversion that the same names
> should not occur again?*
--
This message was sent by Atlassian Jira
(v8.3.4#803005)