moonboots300 edited a comment on issue #4271: Pulsar Avro Schema Enum 
improvement request
URL: https://github.com/apache/pulsar/issues/4271#issuecomment-492797526
 
 
   @codelipenghui, @merlimat  - That is another problem that I would like to 
highlight. Suppose I have a schema that we are currently using in production 
with a Customer that has the following Nullable Avro Enum field - It is Not 
implemented in Pulsar Functions or pulsar API:
   ```
   {
       "name": "exampleEnum",
        "type": ["null", {
                "type": "enum",
                "name": "ExampleEnum",
                "symbols": ["YES", "NO"]
                }
        ]
   }
   ```
   I am doing initial work to see if we can migrate to use Pulsar Functions and 
the Avro tools provided in the pulsar-client instead of the current 
implementation. But...
   If I do AvroSchema.of( <Classname of Pojo> ). I get the following Enum field 
in my definition when marking a field as @Nullable (which is not backwards 
compatible with our current production Schema - the generated schema will have 
**,"default": null** added at the end): 
   
   ```
   {
       "name": "exampleEnum",
        "type": ["null", {
                "type": "enum",
                "name": "ExampleEnum",
                "symbols": ["YES", "NO"]
                }
        ],
        "default": null
   }
   ```
   The use case I have for this one is that I am trying to implement a current 
production Use Case with Pulsar Functions - 1. I use AvroSchema.of() to 
generate the schema and 2. I use schema.encode(OBJECT) to Serialize before 
publishing to a pulsar topic.
   
   If I use the avro-tools jar, following the directions for generating a 
schema along with Using the Avro java library.... I can Serialize / Deserialize 
messages With the Schema definition text file and my POJO that was generated 
from avro-tools jar. Using this workaround along with Pulsar Functions works 
but it is not utilizing the schema.encode() and AvroSchema.of() which is how we 
should be using Avro Schema's with Pulsar and is much more convenient if I 
could do that.
   

----------------------------------------------------------------
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

Reply via email to