jeames00 commented on issue #7695:
URL: https://github.com/apache/pulsar/issues/7695#issuecomment-736871182


   I've fiddled around some more, testing a Python and Java producer 
side-by-side, each one iterating the schema incrementally. It seems that to 
make a Python client produce schema that is compatible with that produced by 
the Java client, the following modification would be necessary:
   
   ```
   class Example(Record):
       @classmethod
       def schema(cls):
   
           schema = super(Example, cls).schema()
   
           for i, x in enumerate([cls._fields[x['name']].default() for x in 
schema['fields']]):
               if schema['fields'][i]['type'][1] == "string":
                   schema['fields'][i]['default'] = None
               if schema['fields'][i]['type'][1] == "int":
                   schema['fields'][i]['type'] = 'int'
               else:
                   pass
   
           return schema
   ```
   
   For example in the generated JSON schema, Python sets an empty string as the 
default for String whereas Java sets it to Null; Python sets an Integer type as 
[ "null", "int" ] whereas Java sets it as "int". I'm sure there are other data 
types to consider. I'm now out of my depth here so will have to defer to others.


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


Reply via email to