任务运行时异常:java.lang.Integer cannot be cast to java.lang.Boolean

问题描述/异常栈

java.lang.RuntimeException: java.lang.ClassCastException: java.lang.Integer cannot be cast to java.lang.Boolean
    at org.apache.flink.table.runtime.operators.join.lookup.LookupJoinWithCalcRunner$CalcCollector.collect(LookupJoinWithCalcRunner.java:82) ~[flink-table-blink_2.11-ne-flink-1.12.4-1.0.0.jar:ne-flink-1.12.4-1.0.0]
    at org.apache.flink.table.runtime.operators.join.lookup.LookupJoinWithCalcRunner$CalcCollector.collect(LookupJoinWithCalcRunner.java:69) ~[flink-table-blink_2.11-ne-flink-1.12.4-1.0.0.jar:ne-flink-1.12.4-1.0.0]
    at org.apache.flink.table.functions.TableFunction.collect(TableFunction.java:196) ~[flink-table-blink_2.11-ne-flink-1.12.4-1.0.0.jar:ne-flink-1.12.4-1.0.0]
    at com.netease.sloth.flink.connector.jdbc.table.SlothJdbcRowDataLookupFunction.eval(SlothJdbcRowDataLookupFunction.java:159) ~[plugin_ne-flink-1.12.4-1.1.1_scala2.12_hive2.1.1-3.8.0-1.2.2-SNAPSHOT.jar:?]
    at LookupFunction$294.flatMap(Unknown Source) ~[?:?]
    at org.apache.flink.table.runtime.operators.join.lookup.LookupJoinRunner.processElement(LookupJoinRunner.java:81) ~[flink-table-blink_2.11-ne-flink-1.12.4-1.0.0.jar:ne-flink-1.12.4-1.0.0]
    at org.apache.flink.table.runtime.operators.join.lookup.LookupJoinRunner.processElement(LookupJoinRunner.java:34) ~[flink-table-blink_2.11-ne-flink-1.12.4-1.0.0.jar:ne-flink-1.12.4-1.0.0]
    at org.apache.flink.streaming.api.operators.ProcessOperator.processElement(ProcessOperator.java:66) ~[plugin_ne-flink-1.12.4-1.1.1_scala2.12_hive2.1.1-3.8.0-1.2.2-SNAPSHOT.jar:?]
    at org.apache.flink.streaming.runtime.tasks.CopyingChainingOutput.pushToOperator(CopyingChainingOutput.java:71) ~[plugin_ne-flink-1.12.4-1.1.1_scala2.12_hive2.1.1-3.8.0-1.2.2-SNAPSHOT.jar:?]
    at org.apache.flink.streaming.runtime.tasks.CopyingChainingOutput.collect(CopyingChainingOutput.java:46) ~[plugin_ne-flink-1.12.4-1.1.1_scala2.12_hive2.1.1-3.8.0-1.2.2-SNAPSHOT.jar:?]
    at org.apache.flink.streaming.runtime.tasks.CopyingChainingOutput.collect(CopyingChainingOutput.java:26) ~[plugin_ne-flink-1.12.4-1.1.1_scala2.12_hive2.1.1-3.8.0-1.2.2-SNAPSHOT.jar:?]
    at org.apache.flink.streaming.api.operators.CountingOutput.collect(CountingOutput.java:50) ~[plugin_ne-flink-1.12.4-1.1.1_scala2.12_hive2.1.1-3.8.0-1.2.2-SNAPSHOT.jar:?]
    at org.apache.flink.streaming.api.operators.CountingOutput.collect(CountingOutput.java:28) ~[plugin_ne-flink-1.12.4-1.1.1_scala2.12_hive2.1.1-3.8.0-1.2.2-SNAPSHOT.jar:?]
    at StreamExecCalc$291.processElement(Unknown Source) ~[?:?]
    at org.apache.flink.streaming.runtime.tasks.CopyingChainingOutput.pushToOperator(CopyingChainingOutput.java:71) ~[plugin_ne-flink-1.12.4-1.1.1_scala2.12_hive2.1.1-3.8.0-1.2.2-SNAPSHOT.jar:?]
    at org.apache.flink.streaming.runtime.tasks.CopyingChainingOutput.collect(CopyingChainingOutput.java:46) ~[plugin_ne-flink-1.12.4-1.1.1_scala2.12_hive2.1.1-3.8.0-1.2.2-SNAPSHOT.jar:?]
    at org.apache.flink.streaming.runtime.tasks.CopyingChainingOutput.collect(CopyingChainingOutput.java:26) ~[plugin_ne-flink-1.12.4-1.1.1_scala2.12_hive2.1.1-3.8.0-1.2.2-SNAPSHOT.jar:?]
    at org.apache.flink.streaming.api.operators.CountingOutput.collect(CountingOutput.java:50) ~[plugin_ne-flink-1.12.4-1.1.1_scala2.12_hive2.1.1-3.8.0-1.2.2-SNAPSHOT.jar:?]
    at org.apache.flink.streaming.api.operators.CountingOutput.collect(CountingOutput.java:28) ~[plugin_ne-flink-1.12.4-1.1.1_scala2.12_hive2.1.1-3.8.0-1.2.2-SNAPSHOT.jar:?]
    at org.apache.flink.streaming.api.operators.TimestampedCollector.collect(TimestampedCollector.java:50) ~[plugin_ne-flink-1.12.4-1.1.1_scala2.12_hive2.1.1-3.8.0-1.2.2-SNAPSHOT.jar:?]
    at org.apache.flink.table.runtime.operators.deduplicate.DeduplicateFunctionHelper.processLastRowOnChangelog(DeduplicateFunctionHelper.java:97) ~[flink-table-blink_2.11-ne-flink-1.12.4-1.0.0.jar:ne-flink-1.12.4-1.0.0]
    at org.apache.flink.table.runtime.operators.deduplicate.ProcTimeDeduplicateKeepLastRowFunction.processElement(ProcTimeDeduplicateKeepLastRowFunction.java:55) ~[flink-table-blink_2.11-ne-flink-1.12.4-1.0.0.jar:ne-flink-1.12.4-1.0.0]
    at org.apache.flink.table.runtime.operators.deduplicate.ProcTimeDeduplicateKeepLastRowFunction.processElement(ProcTimeDeduplicateKeepLastRowFunction.java:29) ~[flink-table-blink_2.11-ne-flink-1.12.4-1.0.0.jar:ne-flink-1.12.4-1.0.0]
    at org.apache.flink.streaming.api.operators.KeyedProcessOperator.processElement(KeyedProcessOperator.java:83) ~[plugin_ne-flink-1.12.4-1.1.1_scala2.12_hive2.1.1-3.8.0-1.2.2-SNAPSHOT.jar:?]
    at org.apache.flink.streaming.runtime.tasks.OneInputStreamTask$StreamTaskNetworkOutput.emitRecord(OneInputStreamTask.java:191) ~[plugin_ne-flink-1.12.4-1.1.1_scala2.12_hive2.1.1-3.8.0-1.2.2-SNAPSHOT.jar:?]
    at org.apache.flink.streaming.runtime.io.StreamTaskNetworkInput.processElement(StreamTaskNetworkInput.java:204) ~[plugin_ne-flink-1.12.4-1.1.1_scala2.12_hive2.1.1-3.8.0-1.2.2-SNAPSHOT.jar:?]
    at org.apache.flink.streaming.runtime.io.StreamTaskNetworkInput.emitNext(StreamTaskNetworkInput.java:174) ~[plugin_ne-flink-1.12.4-1.1.1_scala2.12_hive2.1.1-3.8.0-1.2.2-SNAPSHOT.jar:?]
    at org.apache.flink.streaming.runtime.io.StreamOneInputProcessor.processInput(StreamOneInputProcessor.java:65) ~[plugin_ne-flink-1.12.4-1.1.1_scala2.12_hive2.1.1-3.8.0-1.2.2-SNAPSHOT.jar:?]
    at org.apache.flink.streaming.runtime.tasks.StreamTask.processInput(StreamTask.java:398) ~[plugin_ne-flink-1.12.4-1.1.1_scala2.12_hive2.1.1-3.8.0-1.2.2-SNAPSHOT.jar:?]
    at org.apache.flink.streaming.runtime.tasks.mailbox.MailboxProcessor.runMailboxLoop(MailboxProcessor.java:191) ~[plugin_ne-flink-1.12.4-1.1.1_scala2.12_hive2.1.1-3.8.0-1.2.2-SNAPSHOT.jar:?]
    at org.apache.flink.streaming.runtime.tasks.StreamTask.runMailboxLoop(StreamTask.java:619) ~[plugin_ne-flink-1.12.4-1.1.1_scala2.12_hive2.1.1-3.8.0-1.2.2-SNAPSHOT.jar:?]
    at org.apache.flink.streaming.runtime.tasks.StreamTask.invoke(StreamTask.java:583) ~[plugin_ne-flink-1.12.4-1.1.1_scala2.12_hive2.1.1-3.8.0-1.2.2-SNAPSHOT.jar:?]
    at org.apache.flink.runtime.taskmanager.Task.doRun(Task.java:758) [plugin_ne-flink-1.12.4-1.1.1_scala2.12_hive2.1.1-3.8.0-1.2.2-SNAPSHOT.jar:?]
    at org.apache.flink.runtime.taskmanager.Task.run(Task.java:573) [plugin_ne-flink-1.12.4-1.1.1_scala2.12_hive2.1.1-3.8.0-1.2.2-SNAPSHOT.jar:?]
    at java.lang.Thread.run(Thread.java:748) [?:1.8.0_152]
Caused by: java.lang.ClassCastException: java.lang.Integer cannot be cast to java.lang.Boolean
    at org.apache.flink.table.data.GenericRowData.getBoolean(GenericRowData.java:134) ~[flink-table-blink_2.11-ne-flink-1.12.4-1.0.0.jar:ne-flink-1.12.4-1.0.0]
    at TableCalcMapFunction$332.flatMap(Unknown Source) ~[?:?]
    at org.apache.flink.table.runtime.operators.join.lookup.LookupJoinWithCalcRunner$CalcCollector.collect(LookupJoinWithCalcRunner.java:80) ~[flink-table-blink_2.11-ne-flink-1.12.4-1.0.0.jar:ne-flink-1.12.4-1.0.0]
    ... 34 more

解决方案

 添加参数 'driver' = 'com.netease.sloth.mysql5.jdbc.Driver' ,将JDBC驱动换成 5.x 版本。
 或将数据库升级到更高版本。

问题原因

数据库版本过低导致。

作者:邓崃翔