Closed BewareMyPower closed 1 year ago
A workaround is to change the Python User
definition from
class User(Record):
name = String()
age = Integer()
to
class User(Record):
_sorted_fields = True
name = String()
age = Integer(required=True)
To be compatible with the Java client, we have to configure the required
field of all fields with True
, except String
. In addition, we need to set _sorted_fields
with True
.
How to reproduce
Run a Pulsar standalone 2.11.
First, create a Python consumer whose schema is a class with a string field
name
and an integer fieldage
:Then, set the schema compatibility to
FORWARD
:Then, run the Java producer to send a message (
User{name="xyz", age=10}
):Then, the Python consumer application will crash with the following logs:
Analysis
There are two bugs. First, the schema definition generated by the Python client is different from the Java client. Copy these two classes here:
Check the schema definitions (
pulsar-admin schemas get my-topic -v <version>
) and we can find there are two versions of the schema:We can see:
nullable
fields, (or say it correctly, they are Avro unions), even including theint
fieldnullable
fields since Primitive types cannot benull