BewareMyPower commented on code in PR #119:
URL:
https://github.com/apache/pulsar-client-python/pull/119#discussion_r1203838596
##########
pulsar/schema/schema_avro.py:
##########
@@ -40,6 +42,8 @@ def __init__(self, record_cls, schema_definition=None):
self._schema = record_cls.schema()
else:
self._schema = schema_definition
+ self._writer_schemas = dict()
Review Comment:
`fastavro` uses different APIs with the Java Avro library.
https://fastavro.readthedocs.io/en/latest/reader.html?highlight=schemaless_reader#fastavro._read_py.schemaless_reader
- writer_schema – Schema used when calling schemaless_writer
- reader_schema – If the schema has changed since being written then the new
schema can be given to allow for schema migration
The downloaded schema should be the writer schema because Python producers
pass that schema to `schemaless_writer`.
As for the Pulsar Java client, it seems that your understanding is wrong.
https://github.com/apache/pulsar/blob/b31c5a6a325728b5dc5faebd1a33386952d733d5/pulsar-client/src/main/java/org/apache/pulsar/client/impl/schema/reader/MultiVersionAvroReader.java#L51-L52
```java
return new
AvroReader<>(parseAvroSchema(schemaInfo.getSchemaDefinition()),
readerSchema, pojoClassLoader, jsr310ConversionEnabled);
```
You can see the downloaded schema is the 1st argument to construct an
`AvroReader`.
https://github.com/apache/pulsar/blob/b31c5a6a325728b5dc5faebd1a33386952d733d5/pulsar-client/src/main/java/org/apache/pulsar/client/impl/schema/reader/AvroReader.java#L58
```java
public AvroReader(Schema writerSchema, Schema readerSchema, ClassLoader
classLoader,
```
As you can see, the downloaded schema is the writer schema. The
`MultiVersionAvroReader#readerSchema`, which is passed from the consumer, is
the reader schema.
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]