[ https://issues.apache.org/jira/browse/AVRO-1763?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Thiruvalluvan M. G. updated AVRO-1763: -------------------------------------- Component/s: spec > Avro Schema Generator to handle polymorphic types > ------------------------------------------------- > > Key: AVRO-1763 > URL: https://issues.apache.org/jira/browse/AVRO-1763 > Project: Apache Avro > Issue Type: Improvement > Components: spec > Affects Versions: 1.9.0 > Reporter: Qiangqiang Shi > Priority: Major > > Inheritance and polymorphism are widely used in Java libraries. If multiple > sophisticated Avro schema generator can be added to Avro, users can generate > Avro schema easily for classes in complex context, third-party code and > legacy code. > For example, for the following class: > {code:java} > public class TestReflectPolymorphismData { > { > public static class SuperclassA1 { > private String SuperclassA1; > } > public static class SubclassA1 extends SuperclassA1 { > private String SubclassA1; > } > public static class SubclassA2 extends SuperclassA1 { > private String SubclassA2; > } > public static class SuperB1 { > private SubclassA1 SubclassA1; > private List<SubclassA2> SubclassA2List; > private Map<String, SuperclassA1> stringSuperclassA1Map; > private Map<Integer, SuperclassA1> integerSuperclassA1Map; > } > } > } > {code} > It'll be good if Avro can provide a schema generator to generate a schema > like the following automatically for class SuperB1 : > {code:java} > { > "type": "record", > "name": "SuperB1", > "namespace": "org.apache.avro.reflect.TestReflectPolymorphismData$", > "fields": [ > { > "name": "SubclassA1", > "type": { > "type": "record", > "name": "SuperclassA1", > "fields": [ > { > "name": "SuperclassA1", > "type": "string" > }, > { > "name": "SuperclassA1Subclasses", > "type": [ > "null", > { > "type": "record", > "name": "SubclassA1", > "fields": [ > { > "name": "SubclassA1", > "type": "string" > } > ] > }, > { > "type": "record", > "name": "SubclassA2", > "fields": [ > { > "name": "SubclassA2", > "type": "string" > } > ] > } > ] > } > ] > } > }, > { > "name": "SubclassA2List", > "type": { > "type": "array", > "items": "SuperclassA1", > "java-class": "java.util.List" > } > }, > { > "name": "stringSuperclassA1Map", > "type": { > "type": "map", > "values": "SuperclassA1" > } > }, > { > "name": "integerSuperclassA1Map", > "type": { > "type": "array", > "items": { > "type": "record", > "name": "Pair34255fab6d3d79ff", > "namespace": "org.apache.avro.reflect", > "fields": [ > { > "name": "key", > "type": "int" > }, > { > "name": "value", > "type": > "org.apache.avro.reflect.TestReflectPolymorphismData$.SuperclassA1" > } > ] > }, > "java-class": "java.util.Map" > } > } > ] > } > {code} > related story: AVRO-1568 -- This message was sent by Atlassian JIRA (v7.6.3#76005)