You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by "jiawen xiao (Jira)" <ji...@apache.org> on 2020/12/11 09:41:00 UTC

[jira] [Comment Edited] (FLINK-20386) ClassCastException when lookup join a JDBC table on INT UNSIGNED column

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

jiawen xiao edited comment on FLINK-20386 at 12/11/20, 9:40 AM:
----------------------------------------------------------------

[~jark]

_share my method here which is a large_ _amount_ _of_  _work:_

_we can get jdbc/mysql scheme by DatabaseMetaData and  map to  flink datatype at same time which can be validated with  source table schema or sink table schema. it will throw ValidationException("Field types of mysql-schema result and registered TableSource do not match")  ._

_This idea comes from TableSinkUtils.validateSchemaAndApplyImplicitCast (release 1.11)_

_jark,What do you think?_

 


was (Author: 873925389@qq.com):
[~jark]

_share my method here which is a large_ _amount_ __ _of_ __ _work:_

_we can get jdbc/mysql scheme by DatabaseMetaData and  map to  flink datatype at same time which can be validated with  source table schema or sink table schema. it will throw ValidationException("Field types of mysql-schema result and registered TableSource do not match")  ._

_This idea comes from TableSinkUtils.validateSchemaAndApplyImplicitCast (release 1.11)_

_What do you think,jark_

 

> ClassCastException when lookup join a JDBC table on INT UNSIGNED column
> -----------------------------------------------------------------------
>
>                 Key: FLINK-20386
>                 URL: https://issues.apache.org/jira/browse/FLINK-20386
>             Project: Flink
>          Issue Type: Bug
>          Components: Connectors / JDBC, Table SQL / Ecosystem
>    Affects Versions: 1.12.0, 1.11.2
>            Reporter: Jark Wu
>            Assignee: jiawen xiao
>            Priority: Major
>          Time Spent: 336h
>  Remaining Estimate: 0h
>
> The primary key of the MySQL is an INT UNSIGNED column, but declared INT in Flink. 
> I know the [docs|https://ci.apache.org/projects/flink/flink-docs-release-1.11/dev/table/connectors/jdbc.html#data-type-mapping] say it should be decalred BIGINT in Flink, however, would be better not fail the job. 
> At least, the exception is hard to understand for users. We can also check the schema before start the job. 
> {code}
> java.lang.ClassCastException: java.lang.Long cannot be cast to java.lang.Integer
> 	at org.apache.flink.table.data.GenericRowData.getInt(GenericRowData.java:149) ~[flink-table-blink_2.11-1.11-vvr-2.1.1-SNAPSHOT.jar:1.11-vvr-2.1.1-SNAPSHOT]
> 	at JoinTableFuncCollector$6460.collect(Unknown Source) ~[?:?]
> 	at org.apache.flink.table.functions.TableFunction.collect(TableFunction.java:203) ~[flink-table-blink_2.11-1.11-vvr-2.1.1-SNAPSHOT.jar:1.11-vvr-2.1.1-SNAPSHOT]
> 	at org.apache.flink.connector.jdbc.table.JdbcRowDataLookupFunction.eval(JdbcRowDataLookupFunction.java:162) ~[?:?]
> {code}



--
This message was sent by Atlassian Jira
(v8.3.4#803005)