flink sql 处理时间 时区问题

classic Classic list List threaded Threaded
6 messages Options
hb
Reply | Threaded
Open this post in threaded view
|

flink sql 处理时间 时区问题

hb


``` 代码
  val env = StreamExecutionEnvironment.getExecutionEnvironment
  val settings: EnvironmentSettings = EnvironmentSettings.newInstance().useBlinkPlanner().inStreamingMode().build()
  val tEnv: StreamTableEnvironment = StreamTableEnvironment.create(env, settings)


  val t2 = env.fromElements("a", "b", "c")
  t2.toTable(tEnv, 'f1, 'proc.proctime).toAppendStream[Row].print()
```


  // 时区上海, 当前时间为 2020-05-01 15点
  // 结果显示 a,2020-05-01T09:11:05.633, 处理时间相差8小时, 请问如何让 proctime 结果显示不差8小时.
Reply | Threaded
Open this post in threaded view
|

Re: flink sql 处理时间 时区问题

admin
同问,等待大佬回答

> 2020年5月1日 下午5:26,hb <[hidden email]> 写道:
>
>
>
> ``` 代码
>  val env = StreamExecutionEnvironment.getExecutionEnvironment
>  val settings: EnvironmentSettings = EnvironmentSettings.newInstance().useBlinkPlanner().inStreamingMode().build()
>  val tEnv: StreamTableEnvironment = StreamTableEnvironment.create(env, settings)
>
>
>  val t2 = env.fromElements("a", "b", "c")
>  t2.toTable(tEnv, 'f1, 'proc.proctime).toAppendStream[Row].print()
> ```
>
>
>  // 时区上海, 当前时间为 2020-05-01 15点
>  // 结果显示 a,2020-05-01T09:11:05.633, 处理时间相差8小时, 请问如何让 proctime 结果显示不差8小时.

Reply | Threaded
Open this post in threaded view
|

Re: flink sql 处理时间 时区问题

Jingsong Li
Hi,

这可能是个Bug。

Blink中默认使用timestamp WITHOUT time zone,所以它是无时区的。
而proctime目前还是带时区的产生了时间,我理解可能是应该产生无时区的时间。

CC: @Jark Wu <[hidden email]> @Zhenghua Gao <[hidden email]>

Best,
Jingsong Lee

On Tue, May 5, 2020 at 5:43 PM 祝尚 <[hidden email]> wrote:

> 同问,等待大佬回答
>
> > 2020年5月1日 下午5:26,hb <[hidden email]> 写道:
> >
> >
> >
> > ``` 代码
> >  val env = StreamExecutionEnvironment.getExecutionEnvironment
> >  val settings: EnvironmentSettings =
> EnvironmentSettings.newInstance().useBlinkPlanner().inStreamingMode().build()
> >  val tEnv: StreamTableEnvironment = StreamTableEnvironment.create(env,
> settings)
> >
> >
> >  val t2 = env.fromElements("a", "b", "c")
> >  t2.toTable(tEnv, 'f1, 'proc.proctime).toAppendStream[Row].print()
> > ```
> >
> >
> >  // 时区上海, 当前时间为 2020-05-01 15点
> >  // 结果显示 a,2020-05-01T09:11:05.633, 处理时间相差8小时, 请问如何让 proctime 结果显示不差8小时.
>
>

--
Best, Jingsong Lee
Reply | Threaded
Open this post in threaded view
|

Re: flink sql 处理时间 时区问题

Jark
Administrator
Yes. 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.

Best,
Jark

On Wed, 6 May 2020 at 09:47, Jingsong Li <[hidden email]> wrote:

> Hi,
>
> 这可能是个Bug。
>
> Blink中默认使用timestamp WITHOUT time zone,所以它是无时区的。
> 而proctime目前还是带时区的产生了时间,我理解可能是应该产生无时区的时间。
>
> CC: @Jark Wu <[hidden email]> @Zhenghua Gao <[hidden email]>
>
> Best,
> Jingsong Lee
>
> On Tue, May 5, 2020 at 5:43 PM 祝尚 <[hidden email]> wrote:
>
>> 同问,等待大佬回答
>>
>> > 2020年5月1日 下午5:26,hb <[hidden email]> 写道:
>> >
>> >
>> >
>> > ``` 代码
>> >  val env = StreamExecutionEnvironment.getExecutionEnvironment
>> >  val settings: EnvironmentSettings =
>> EnvironmentSettings.newInstance().useBlinkPlanner().inStreamingMode().build()
>> >  val tEnv: StreamTableEnvironment = StreamTableEnvironment.create(env,
>> settings)
>> >
>> >
>> >  val t2 = env.fromElements("a", "b", "c")
>> >  t2.toTable(tEnv, 'f1, 'proc.proctime).toAppendStream[Row].print()
>> > ```
>> >
>> >
>> >  // 时区上海, 当前时间为 2020-05-01 15点
>> >  // 结果显示 a,2020-05-01T09:11:05.633, 处理时间相差8小时, 请问如何让 proctime 结果显示不差8小时.
>>
>>
>
> --
> Best, Jingsong Lee
>
hb
Reply | Threaded
Open this post in threaded view
|

Re:flink sql 处理时间 时区问题

hb
In reply to this post by hb
有人能帮忙看下这个问题么



在 2020-05-01 16:26:35,"hb" <[hidden email]> 写道:



``` 代码
  val env = StreamExecutionEnvironment.getExecutionEnvironment
  val settings: EnvironmentSettings = EnvironmentSettings.newInstance().useBlinkPlanner().inStreamingMode().build()
  val tEnv: StreamTableEnvironment = StreamTableEnvironment.create(env, settings)


  val t2 = env.fromElements("a", "b", "c")
  t2.toTable(tEnv, 'f1, 'proc.proctime).toAppendStream[Row].print()
```


  // 时区上海, 当前时间为 2020-05-01 15点
  // 结果显示 a,2020-05-01T09:11:05.633, 处理时间相差8小时, 请问如何让 proctime 结果显示不差8小时.




 
Reply | Threaded
Open this post in threaded view
|

Re: Re:flink sql 处理时间 时区问题

刘大龙
Hi,
一种简单的方式,自己手动在proctime上加8个小时,目前这个时区设置好像是不起作用的。


> -----原始邮件-----
> 发件人: hb <[hidden email]>
> 发送时间: 2020-05-12 13:02:44 (星期二)
> 收件人: [hidden email]
> 抄送:
> 主题: Re:flink sql 处理时间 时区问题
>
> 有人能帮忙看下这个问题么
>
>
>
> 在 2020-05-01 16:26:35,"hb" <[hidden email]> 写道:
>
>
>
> ``` 代码
>   val env = StreamExecutionEnvironment.getExecutionEnvironment
>   val settings: EnvironmentSettings = EnvironmentSettings.newInstance().useBlinkPlanner().inStreamingMode().build()
>   val tEnv: StreamTableEnvironment = StreamTableEnvironment.create(env, settings)
>
>
>   val t2 = env.fromElements("a", "b", "c")
>   t2.toTable(tEnv, 'f1, 'proc.proctime).toAppendStream[Row].print()
> ```
>
>
>   // 时区上海, 当前时间为 2020-05-01 15点
>   // 结果显示 a,2020-05-01T09:11:05.633, 处理时间相差8小时, 请问如何让 proctime 结果显示不差8小时.
>
>
>
>
>


------------------------------
刘大龙

浙江大学 控制系 智能系统与控制研究所 工控新楼217
地址:浙江省杭州市浙大路38号浙江大学玉泉校区
Tel:18867547281