[ 
https://issues.apache.org/jira/browse/FLINK-37469?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Munir Contractor updated FLINK-37469:
-------------------------------------
    Component/s: API / Type Serialization System

> ClassCastException in org.apache.flink.table.data.GenericRowData
> ----------------------------------------------------------------
>
>                 Key: FLINK-37469
>                 URL: https://issues.apache.org/jira/browse/FLINK-37469
>             Project: Flink
>          Issue Type: Bug
>          Components: API / Type Serialization System
>         Environment: Flink 1.19.2
>            Reporter: Munir Contractor
>            Priority: Minor
>
> In my application,  I am reading AVRO data from Kafka using KafkaSource. The 
> data is deserialized as AVRO `GenericRecord` and eventually sent to a sink 
> that writes it to Iceberg tables. During execution, I see the following stack 
> trace, once the sink tries to write the data.
>  
> {code:java}
> Caused by: java.lang.ClassCastException: class java.lang.Integer cannot be 
> cast to class java.lang.Long (java.lang.Integer and java.lang.Long are in 
> module java.base of loader 'bootstrap')
> at org.apache.flink.table.data.GenericRowData.getLong(GenericRowData.java:154)
> at 
> org.apache.flink.table.data.RowData.lambda$createFieldGetter$245ca7d1$7(RowData.java:249)
> at 
> org.apache.flink.table.runtime.typeutils.RowDataSerializer.copyRowData(RowDataSerializer.java:170)
> at 
> org.apache.flink.table.runtime.typeutils.RowDataSerializer.copy(RowDataSerializer.java:131)
> at 
> org.apache.flink.table.runtime.typeutils.RowDataSerializer.copy(RowDataSerializer.java:48)
> at 
> org.apache.flink.streaming.runtime.tasks.CopyingChainingOutput.pushToOperator(CopyingChainingOutput.java:74)
>  {code}
> Looking through the code for the class, the method does {{return (long) 
> this.fields[pos]) }}where fields is an array of Object. Because the array has 
> type Object, the values cannot be directly cast as primitives, but should be 
> converted to Number, and converted with the appropriate method, i.e. {{return 
> ((Number) this.fields[pos]).longValue();}} Other methods in the class are 
> also susceptible to this bug.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to