美文网首页
flink sql 时区不对

flink sql 时区不对

作者: 邵红晓 | 来源:发表于2020-05-13 18:48 被阅读0次
  • proc.proctime的模式格式是 java.sql.Timestamp
  • 发现时间不对,现在时间18:44:00,相差8小时
 def main(args: Array[String]): Unit = {
    val env = StreamExecutionEnvironment.getExecutionEnvironment
    val settings: EnvironmentSettings = EnvironmentSettings.newInstance().useOldPlanner().inStreamingMode().build()
    val tEnv: StreamTableEnvironment = StreamTableEnvironment.create(env, settings)
    import org.apache.flink.api.scala._
    //注意这里的隐式转换
    val t2 = env.fromElements[String]("hello", "world", "flink")
    //注意这里的隐式转换 toTable
    import org.apache.flink.table.api.scala._
     t2.toTable(tEnv, 'f1,'proc.proctime).toAppendStream[Row].print()
//    tEnv.sqlQuery(s"select * from $r").toAppendStream[(String,Timestamp)].print()

    /** proctime 格式是import java.sql.Timestamp格式,发现时间不对时区问题
      * 8> hello,2020-05-13 10:44:20.51
2> flink,2020-05-13 10:44:20.51
1> world,2020-05-13 10:44:20.51
      */
    env.execute()
  • 解答:
    This is the same problem with CURRENT_TIMESTAMP which was asked before
    in mailing list and JIRA.
    Changing the return type to WITH LOCAL TIME ZONE is not a small work, we
    should make event-time and watermark support this type.
    But I think this is in a high priority and should be fixed in the next
    release.

相关文章

网友评论

      本文标题:flink sql 时区不对

      本文链接:https://www.haomeiwen.com/subject/opsonhtx.html