You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@spark.apache.org by "Kevin Zhang (JIRA)" <ji...@apache.org> on 2017/08/08 06:06:00 UTC

[jira] [Comment Edited] (SPARK-21590) Structured Streaming window start time should support negative values to adjust time zone

    [ https://issues.apache.org/jira/browse/SPARK-21590?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16117900#comment-16117900 ] 

Kevin Zhang edited comment on SPARK-21590 at 8/8/17 6:05 AM:
-------------------------------------------------------------

[~brkyvz] Thanks for your advice, but I believe you don't completely understand the problem. Let me talk about what I found unreasonable and that' s why I'm here opening the issue. 

Before digging into adjusting start offset of the window, I've tried using from_utc_timestamp (even to_utc_timestamp) and set the timezone of jvm to CST, but all of these cannot get the right result, because all the timestamps of my events are generated in CST,  if I use from_utc_timestamp to convert the timestamp of all events to utc time , take today (2017-08-08) as example, I finally get a window of *yesterday* starting at 8 o'clock like [2017-08-07 08:00:00.0,2017-08-08 08:00:00.0], instead of the window of *today* starting at 00:00. 

Other methods are also incorrect and won't be covered again here. So the problem is I have the correct timestamp and can get the right date of window, but the only thing weird is the 8 hours start offset. That's why I want to set the start offset to -8 to adjust the window, and I think it's very reasonable because flink [https://ci.apache.org/projects/flink/flink-docs-release-1.3/dev/windows.html] runs exactly in this way.

As for "+16" offset, I've told that it works well, like what you described in your example for something happened in  2017-03-14 17:30:00 CST I can get a window of 2017-03-14 00:00 CST - 2017-03-15 00:00 CST . 

But the confusing thing is that with "+16" why I don't get a window of 2017-03-15 00:00 CST - 2017-03-16 00:00 CST? Also I tried "+15" I'll get a window of 2017-03-13 23:00 CST - 2017-03-14 23:00 CST, the beginning time of window falls back to yesterday? Don't you think it's kind of confusing for users?


was (Author: kevinzwx):
[~brkyvz] Thanks for your advice, but I believe you don't completely understand the problem. Let me talk about what I found unreasonable and that' s why I'm here opening the issue. 

Before digging into adjusting start offset of the window, I've tried using from_utc_timestamp (even to_utc_timestamp) and set the timezone of jvm to CST, but all of these cannot get the right result, because all the timestamps of my events are generated in CST,  if I use from_utc_timestamp to convert the timestamp of all events to utc time , take today (2017-08-08) as example, I finally get a window of *yesterday* starting at 8 o'clock like [2017-08-07 08:00:00.0,2017-08-08 08:00:00.0], instead of the window of *today* starting at 00:00. Other methods are also incorrect and won't be covered again here. So the problem is I have the correct timestamp and can get the right date of window, but the only thing weird is the 8 hours start offset. That's why I want to set the start offset to -8 to adjust the window, and I think it's very reasonable because flink [https://ci.apache.org/projects/flink/flink-docs-release-1.3/dev/windows.html] runs exactly in this way.

As for "+16" offset, I've told that it works well, like what you described in your example for something happened in  2017-03-14 17:30:00 CST I can get a window of 2017-03-14 00:00 CST - 2017-03-15 00:00 CST . But the confusing thing is that with "+16" why I don't get a window of 2017-03-15 00:00 CST - 2017-03-16 00:00 CST? Also I tried "+15" I'll get a window of 2017-03-13 23:00 CST - 2017-03-14 23:00 CST, the beginning time of window falls back to yesterday? Don't you think it's kind of confusing for users?

> Structured Streaming window start time should support negative values to adjust time zone
> -----------------------------------------------------------------------------------------
>
>                 Key: SPARK-21590
>                 URL: https://issues.apache.org/jira/browse/SPARK-21590
>             Project: Spark
>          Issue Type: Bug
>          Components: Structured Streaming
>    Affects Versions: 2.0.0, 2.0.1, 2.1.0, 2.2.0
>         Environment: spark 2.2.0
>            Reporter: Kevin Zhang
>              Labels: spark-sql, spark2.2, streaming, structured, timezone, window
>
> I want to calculate (unique) daily access count using structured streaming (2.2.0). 
> Now strut streaming' s window with 1 day duration starts at 
> 00:00:00 UTC and ends at 23:59:59 UTC each day, but my local timezone is CST (UTC + 8 hours) and I
> want date boundaries to be 00:00:00 CST (that is 00:00:00 UTC - 8). 
> In Flink I can set the window offset to -8 hours to make it, but here in struct streaming if I set the start time (same as the offset in Flink) to -8 or any other negative values, I will get the following error:
> {code:java}
> Exception in thread "main" org.apache.spark.sql.AnalysisException: cannot resolve 'timewindow(timestamp, 86400000000, 86400000000, -28800000000)' due to data type mismatch: The start time (-28800000000) must be greater than or equal to 0.;;
> {code}
> because the time window checks the input parameters to guarantee each value is greater than or equal to 0.
> So I'm thinking about whether we can remove the limit that the start time cannot be negative?



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@spark.apache.org
For additional commands, e-mail: issues-help@spark.apache.org