[ 
https://issues.apache.org/jira/browse/AVRO-3520?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17541165#comment-17541165
 ] 

Ashley Taylor commented on AVRO-3520:
-------------------------------------

Hello, I have been working on  AVRO-3126 and ran into the same issue with 
adding a field to an existing file.

In my draft implementation, I had Avro instantiate a special custom encoder 
that passed the schema and class as constructor arguments.

But with this PR, if the setReadSchema were extended to pass the class as a 
second argument, It would be identical to any other schema and allow for 
powerful custom encoders to be experimented with without needing to change 
Avro. For example, an automatically polymorphic encoder using sealed classes 
could be prototyped outside Avro.

 

If the schema were moved from the standalone method to each row, the rather 
expensive setup would either be done each time or have to check a boolean to 
see if it's initialised.

Since the schema information is stored at the top of each file wouldn't it be 
impossible to have the schema change during a read?

And if the next file did have a different schema, wouldn't that create another 
custom encoder instance since that would be a different schema in the lookup?

 

 

 

 

> CustomEncoding doesn't expose the read schema
> ---------------------------------------------
>
>                 Key: AVRO-3520
>                 URL: https://issues.apache.org/jira/browse/AVRO-3520
>             Project: Apache Avro
>          Issue Type: Bug
>          Components: java
>    Affects Versions: 1.11.0
>            Reporter: Colin
>            Priority: Major
>              Labels: pull-request-available
>         Attachments: patchTest.txt
>
>          Time Spent: 10m
>  Remaining Estimate: 0h
>
> Currently it is not possible to detect a schema change when using 
> `CustomEncoding<T>`.



--
This message was sent by Atlassian Jira
(v8.20.7#820007)

Reply via email to