You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by GitBox <gi...@apache.org> on 2020/11/04 09:42:02 UTC

[GitHub] [flink] sunnylohani commented on pull request #7584: [FLINK-11030] Make SpecificData of AvroDeserializationScheme configurable

sunnylohani commented on pull request #7584:
URL: https://github.com/apache/flink/pull/7584#issuecomment-721624880


   @dawidwys 
   I am using avro 1.10.0 with Flink Kafka source connector. Can you please explain some details on the workaround you have spoken above ?
   I have _java.time.LocalDateTime_ field in my POJO generated by avro-maven plugin. Below is the plugin:
   
   ```
   <plugin>
           <groupId>org.apache.avro</groupId>
           <artifactId>avro-maven-plugin</artifactId>
           <version>${avro.version}</version>
           <configuration>
             <stringType>String</stringType>
             <enableDecimalLogicalType>true</enableDecimalLogicalType>
             <customConversions>
               org.apache.avro.data.TimeConversions$LocalTimestampMicrosConversion
             </customConversions>
           </configuration>
           <executions>
             <execution>
               <phase>generate-sources</phase>
               <goals>
                 <goal>schema</goal>
               </goals>
               <configuration>
                 <sourceDirectory>${project.basedir}/src/main/resources/schema</sourceDirectory>
                 <outputDirectory>${project.build.directory}/generated-sources/avro</outputDirectory>
               </configuration>
             </execution>
           </executions>
         </plugin>
   ```
   
   But I get below exception when my Flink job receives an avro encoded event from kafka:
   
   _...
   Caused by: java.lang.ClassCastException: java.lang.Long cannot be cast to java.time.LocalDateTime
           ...
   	at org.apache.avro.generic.GenericData.setField(GenericData.java:819)
   	at org.apache.avro.specific.SpecificDatumReader.readField(SpecificDatumReader.java:139)
   	at org.apache.avro.generic.GenericDatumReader.readRecord(GenericDatumReader.java:247)
   	at org.apache.avro.specific.SpecificDatumReader.readRecord(SpecificDatumReader.java:123)
   	at org.apache.avro.generic.GenericDatumReader.readWithoutConversion(GenericDatumReader.java:179)
   	at org.apache.avro.generic.GenericDatumReader.read(GenericDatumReader.java:160)
   	at org.apache.avro.generic.GenericDatumReader.read(GenericDatumReader.java:153)
   	at org.apache.flink.formats.avro.RegistryAvroDeserializationSchema.deserialize(RegistryAvroDeserializationSchema.java:74)_


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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org