moonboots300 commented on issue #4271: Pulsar Avro Schema Enum improvement request URL: https://github.com/apache/pulsar/issues/4271#issuecomment-492062989 One last thing. The issue with java Enums still exists as I stated in the original post. I revisited and realized it was not working as I thought. See below: In java, Building a Schema with Enums and withAlwaysAllowNull(false) is too restrictive. Suppose I have an AvroSchema that is defined by a java Class with two Enums, one that is required and one that is not required. I can only choose: withAlwaysAllowNull(true) -> Both are marked null **or** withAlwaysAllowNull(false) -> Both are marked as required ``` public class Payload{ private Event event; private Direction direction; ..... public enum Event { OPEN, CLOSE } public enum Direction { UP, DOWN } } ``` Create an AvroSchema - Neither of the following will give the desired Schema ``` AvroSchema<Payload> avroSchema = AvroSchema.of(SchemaDefinition.<Payload>builder().withPojo(Payload.class).**withAlwaysAllowNull(false)**.build()); //OR AvroSchema<Payload> avroSchema = AvroSchema.of(SchemaDefinition.<Payload>builder().withPojo(Payload.class).**withAlwaysAllowNull(true)**.build()); //OR AvroSchema<Payload> avroSchema = AvroSchema.of(SchemaDefinition.<Payload>builder().withPojo(Payload.class).build()); ``` Desired Schema: (One Nullable - event, and One Required - direction enum symbols) ``` { "type": "record", "name": "Payload", "namespace": "com.test", "fields": [ { "name": "event", "type": { "type": "enum", "name": "Event", "symbols": ["OPEN", "CLOSE"] } }, { "name": "direction", "type": ["null",{ "type": "enum", "name": "Direction", "symbols": ["UP", "DOWN"] }] } ] } ```
---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [email protected] With regards, Apache Git Services
