开发者社区> 问答> 正文

flink1.9中blinkSQL对定义udf的TIMESTAMP类型报错

社区的各位大佬好:

使用场景:flink1.9版本使用flinkSQL创建udf函数使用没有问,当切换到blinkSQL使用这个udf就会报错TIMESTAMP类型错误,udf实现的功能也很简单,就是将时间+8小时,报错信息如下

org.apache.flink.client.program.ProgramInvocationException: The main method caused an error: Not support dataType: TIMESTAMP(9)         at org.apache.flink.client.program.PackagedProgram.callMainMethod(PackagedProgram.java:593)         at org.apache.flink.client.program.PackagedProgram.invokeInteractiveModeForExecution(PackagedProgram.java:438)         at org.apache.flink.client.program.OptimizerPlanEnvironment.getOptimizedPlan(OptimizerPlanEnvironment.java:83)         at org.apache.flink.client.program.PackagedProgramUtils.createJobGraph(PackagedProgramUtils.java:80)         at org.apache.flink.client.program.PackagedProgramUtils.createJobGraph(PackagedProgramUtils.java:122)         at org.apache.flink.client.cli.CliFrontend.runProgram(CliFrontend.java:227)         at org.apache.flink.client.cli.CliFrontend.run(CliFrontend.java:205)         at org.apache.flink.client.cli.CliFrontend.parseParameters(CliFrontend.java:1010)         at org.apache.flink.client.cli.CliFrontend.lambda$main$10(CliFrontend.java:1083)         at java.security.AccessController.doPrivileged(Native Method)         at javax.security.auth.Subject.doAs(Subject.java:422)         at org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1754)         at org.apache.flink.runtime.security.HadoopSecurityContext.runSecured(HadoopSecurityContext.java:41)         at org.apache.flink.client.cli.CliFrontend.main(CliFrontend.java:1083) Caused by: java.lang.RuntimeException: Not support dataType: TIMESTAMP(9)         at org.apache.flink.table.dataformat.DataFormatConverters.getConverterForDataType(DataFormatConverters.java:248)         at org.apache.flink.table.planner.codegen.CodeGenUtils$.isConverterIdentity(CodeGenUtils.scala:661)         at org.apache.flink.table.planner.codegen.CodeGenUtils$.genToInternal(CodeGenUtils.scala:669)         at org.apache.flink.table.planner.codegen.CodeGenUtils$.genToInternal(CodeGenUtils.scala:665)         at org.apache.flink.table.planner.codegen.CodeGenUtils$.genToInternalIfNeeded(CodeGenUtils.scala:687)         at org.apache.flink.table.planner.codegen.calls.ScalarFunctionCallGen.generate(ScalarFunctionCallGen.scala:79)         at org.apache.flink.table.planner.codegen.ExprCodeGenerator.generateCallExpression(ExprCodeGenerator.scala:737)         at org.apache.flink.table.planner.codegen.ExprCodeGenerator.visitCall(ExprCodeGenerator.scala:451)         at org.apache.flink.table.planner.codegen.ExprCodeGenerator.visitCall(ExprCodeGenerator.scala:51)         at org.apache.calcite.rex.RexCall.accept(RexCall.java:191)         at org.apache.flink.table.planner.codegen.ExprCodeGenerator.generateExpression(ExprCodeGenerator.scala:131)         at org.apache.flink.table.planner.codegen.CalcCodeGenerator$$anonfun$5.apply(CalcCodeGenerator.scala:150)         at org.apache.flink.table.planner.codegen.CalcCodeGenerator$$anonfun$5.apply(CalcCodeGenerator.scala:150)         at scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:234)         at scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:234)         at scala.collection.mutable.ResizableArray$class.foreach(ResizableArray.scala:59)         at scala.collection.mutable.ArrayBuffer.foreach(ArrayBuffer.scala:48)         at scala.collection.TraversableLike$class.map(TraversableLike.scala:234)         at scala.collection.AbstractTraversable.map(Traversable.scala:104)*来自志愿者整理的flink邮件归档

展开
收起
毛毛虫雨 2021-12-08 11:04:21 1304 0
2 条回答
写回答
取消 提交回答
  • 技术小白

    +8是想解决本身函数中的时区问题吧,可以直接用localtimestamp 这个没有时区问题。这样就不用自定义函数了

    2022-03-28 16:21:36
    赞同 展开评论 打赏
  • 你声明了DataType吗?代码怎么写的? 由于目前只支持精度<=3,所以你得用DataTypes.TIMESTAMP(3)来表示。*来自志愿者整理的flink邮件归档

    2021-12-08 15:33:11
    赞同 展开评论 打赏
问答排行榜
最热
最新

相关电子书

更多
Flink CDC Meetup PPT - 龚中强 立即下载
Flink CDC Meetup PPT - 王赫 立即下载
Flink CDC Meetup PPT - 覃立辉 立即下载