flink sql 时区不对

  • 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.
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。