Caused by: org.apache.flink.api.common.io.ParseException: Row too short:
Flink版本
1.17.2
错误描述
Caused by: org.apache.flink.api.common.io.ParseException: Row too short:
通过flink中的flinkSql直接使用对应的connector去获取csv文件内容,报获取的数据太短了
可能原因
1.创建的表字段多于csv文件当中的表头
定位
在获取csv的时候,没有设置分割符,导致整个csv内容识别异常,匹配不上
解决方式
(1)当前问题解决
" 'connector.type' = 'filesystem'," +
" 'format.type' = 'csv'," +
" 'connector.path' = '" + path + "'," +
" 'format.field-delimiter' = '" + fieldDelimiter + "'" +
path为文件地址, fieldDelimiter为分隔符,文件内容是字段|字段的格式,所以fieldDelimiter为|
(2)字段忽略
配置'format.ignore-parse-errors' = 'true'忽略字段不同
" 'connector.type' = 'filesystem'," +
" 'format.type' = 'csv'," +
" 'connector.path' = '" + path + "'," +" 'format.ignore-parse-errors' = 'true'," +
" 'format.field-delimiter' = '" + fieldDelimiter + "'" +
启用后,正常,但是上实际数据会缺失,适合字段是动态的场景,不适合排查是哪个字段不匹配的情况