应该是有内置的 UDF FROM_UNIXTIME 可以用的 Best, tison.
Leonard Xu <[email protected]> 于2020年4月22日周三 下午1:15写道: > Hi > 报错是因为'format.ignore-parse-errors' > 参数是在社区最新的版本才支持的,FLINK-16725在1.11应该也会修复,如果需要使用的话可以等1.11发布后使用或者自己编译master分支, > 即使有了这个参数你的问题也无法解决,对你的case每行记录都会解析错误所以会过滤掉所有数据。 > 建议你可以在数据源就转为标准的json格式或者写个udf将long转为timestamp后使用。 > > 祝好, > Leonard Xu > > > 在 2020年4月22日,12:33,王双利 <[email protected]> 写道: > > > > 要不你们再做一个fastjson版本的? > > 目前内部解析用的都是fastjson > > > > > > > > 发件人: 王双利 > > 发送时间: 2020-04-22 12:31 > > 收件人: user-zh > > 主题: 回复: Re: json中date类型解析失败 > > 配置后报错误 , > > 'format.ignore-parse-errors' = 'true' > > 这个参数需要怎么配置呢? > > The matching candidates: > > org.apache.flink.formats.json.JsonRowFormatFactory > > Unsupported property keys: > > format.ignore-parse-errors > > WITH ( > > ...... > > 'format.type' = 'json', > > 'format.ignore-parse-errors' = 'true', > > .... > > ) > > > > > > > > 发件人: Leonard Xu > > 发送时间: 2020-04-22 12:18 > > 收件人: user-zh; 王双利 > > 主题: Re: json中date类型解析失败 > > Hi, > > flink支持的json format是遵循RFC标准[1]的,不支持从long型转化为json timestamp, json的 > tiemstamp类型转化可以简单参考下,这个虽然符合标准,单对用户习惯来说确实不友好,目前社区也有一个jira[2]在跟进这个问题了。关于鲁棒性的问题,json > format有个参数支持跳过解析错误的记录,'format.ignore-parse-errors' = 'true' > > > > > > ``` > > Long time = System.currentTimeMillis(); > > DateFormat dateFormat = new > SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"); > > Date date = new Date(time); > > String jsonSchemaDate = dateFormat.format(date); > > ``` > > [1] > https://json-schema.org/understanding-json-schema/reference/string.html#dates-and-times > > [2] https://issues.apache.org/jira/browse/FLINK-16725 < > https://issues.apache.org/jira/browse/FLINK-16725> > > > > Best, > > Leonard Xu > > > >> 在 2020年4月22日,12:05,王双利 <[email protected]> 写道: > >> > >> 使用 flink-json -1.10.0 解析json数据报下面的错误 > >> > >> Caused by: java.time.format.DateTimeParseException: Text > '1587527019680' could not be parsed at index 0 > >> > >> 经检查 是 以下字段导致的 > >> > {"jnlno":"e4574cce-8c9f-4d3f-974f-fc15250ec10d","ip":"122.96.41.218","channel":"pc","transdate":1587527019680,"event":"login","userid":"9","deviceid":"111111","taskid":"1","retcode":"000000","status":"fail"} > >> > >> 其中 transdate 是使用fastjson序列化得来的 > >> > request.put("transdate",cal.getTime());JSON.toJSONString(request),解析失败后,系统直接停止,这个觉得也不太好吧,鲁棒性不够,万一其他系统发送一个错误格式的,系统直接挂掉,感觉不太合理。 > >> 以上的应该怎么解决才合适。 > >> > >> > > > >
