m8719-github commented on PR #3616:
URL: https://github.com/apache/avro/pull/3616#issuecomment-3733774083

   Just run into what looks to be related with logical decimal type:
   ```
   java.lang.ClassCastException: class java.math.BigDecimal cannot be cast to 
class java.nio.ByteBuffer
   ```
   This is because the schema has a `bytes` field annotated with the decimal 
logical type, but the POJO is generated via maven avro plugin with 
`enableDecimalLogicalType = false` (the default) and so the receiving instance 
field type `java.nio.ByteBuffer` is miss-matched.
   
   
[This](https://github.com/apache/avro/blob/cbc457da80df85336e1ee792cbbcbb02513dbeb9/lang/java/avro/src/main/java/org/apache/avro/io/FastReaderBuilder.java#L249-L265)
 logic is responsible for attaching conversions based on schema logical type 
annotations; a possible fix would involve interrogating the receiving instance 
via reflection for receiving field type and matching this with what's returned 
from `Conversion.getConvertedType()` or simply an informational/documentation 
fix stating that schema logical type annotations have to be accompanied by 
`enableDecimalLogicalType = true` setting in the avro compiler.


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