liu-du commented on a change in pull request #1355:
URL: https://github.com/apache/avro/pull/1355#discussion_r779481230



##########
File path: 
lang/java/avro/src/main/java/org/apache/avro/reflect/ReflectDatumReader.java
##########
@@ -287,6 +288,26 @@ protected void readField(Object record, Field field, 
Object oldDatum, ResolvingD
             return;
           }
         }
+
+        if (field.schema().isUnion()) {

Review comment:
       I like the idea of adding target type property to the schema and 
overriding the `GenericDatumReader#read` method in `ReflectDatumReader`. I 
tried it by adding a property `SpecificData.CLASS_PROP` (java-class) indicating 
java class for logical types (it seems CLASS_PROP is the conventional property 
name used to indicate java class in the code base). It broke a few unit tests 
but they're easy to fix. 
   
   It almost worked but when I tried fixing the last broken unit test 
`TestReflectLogicalTypes.testReflectedSchemaLocalDateTime`, I got the following 
exception: 
   
![image](https://user-images.githubusercontent.com/34998797/148373820-9d31671d-d024-496d-a94e-a1b4477d369e.png)
   
   Although I was able to add java-class property to schema with a logical 
type, it seems some code assumes logical types should not be used with 
java-class. PS: The code changes are here, though I'm no longer sure we should 
go this way: 
https://github.com/liu-du/avro/commit/6320aae25b6f3c8f10d48b6b4e0fd31d03ebd1bd .
   
   




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


Reply via email to