pulsar-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] [pulsar] jerrypeng commented on issue #3741: POJO AvroSchema always allowNull
Date Tue, 05 Mar 2019 05:11:19 GMT
jerrypeng commented on issue #3741: POJO AvroSchema always allowNull
URL: https://github.com/apache/pulsar/issues/3741#issuecomment-469540392
 
 
   @sijie @skyrocknroll I just experimented a little.
   
   Given the schema that @skyrocknroll posted on the pulsar chat as an example:
   
   ```
   {
     "namespace": "example.avro",
     "type": "record",
     "name": "User",
     "fields": [
       {
         "name": "name",
         "type": "string"
       },
       {
         "name": "favorite_number",
         "type": [
           "int",
           "null"
         ]
       },
       {
         "name": "favorite_color",
         "type": "string"
       },
       {
         "name": "age",
         "type": "int",
         "default": 19
       }
     ]
   }
   ```
   
   I did some tests using the generated java class with the ReflectData schema generator:
   
   ```
   log.info("{}", new String(AvroSchema.of(User.class).getSchemaInfo().getSchema()));
   
   log.info("{}", ReflectData.get().getSchema(User.class));
   
   log.info("{}", ReflectData.AllowNull.get().getSchema(User.class));
   ```
   
   They all produced the same result:
   
   ```
   21:07:27.741 [main:org.company.Test4@44] INFO  org.company.Test4 - {"type":"record","name":"User","namespace":"example.avro","fields":[{"name":"name","type":"string"},{"name":"favorite_number","type":["int","null"]},{"name":"favorite_color","type":"string"},{"name":"age","type":"int","default":19}]}
   
   21:07:27.746 [main:org.company.Test4@46] INFO  org.company.Test4 - {"type":"record","name":"User","namespace":"example.avro","fields":[{"name":"name","type":"string"},{"name":"favorite_number","type":["int","null"]},{"name":"favorite_color","type":"string"},{"name":"age","type":"int","default":19}]}
   
   21:07:27.746 [main:org.company.Test4@48] INFO  org.company.Test4 - {"type":"record","name":"User","namespace":"example.avro","fields":[{"name":"name","type":"string"},{"name":"favorite_number","type":["int","null"]},{"name":"favorite_color","type":"string"},{"name":"age","type":"int","default":19}]}
   ```
   
   regardless of  whether AllowNull is set or not.  So my question still holds what exactly
does removing AllowNull change?
   
   

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

Mime
View raw message