Re: [Flink-SQL] FLOORing OR CEILing a DATE or TIMESTAMP to WEEK uses Thursdays as week start

2021-03-04 Thread Leonard Xu
Post the created Jira link https://issues.apache.org/jira/browse/FLINK-21624 Best, Leonard > > Thanks a lot for the added context and pointers Julian and Leonard, > > I've fixed it by going down to the arithmetics as suggested in one of

Re: [Flink-SQL] FLOORing OR CEILing a DATE or TIMESTAMP to WEEK uses Thursdays as week start

2021-03-03 Thread Sebastián Magrí
Thanks a lot for the added context and pointers Julian and Leonard, I've fixed it by going down to the arithmetics as suggested in one of the Calcite discussions. The changes proposed by FLIP-126 definitely look good. I'll check its details further. Best Regards, On Thu, 4 Mar 2021 at 04:18,

Re: [Flink-SQL] FLOORing OR CEILing a DATE or TIMESTAMP to WEEK uses Thursdays as week start

2021-03-03 Thread Leonard Xu
Hi, Sebastián Ramírez Magrí (Sorry for wrong name in above mail) Flink follows old version calcite’s behaviour which lead to the wrong behavior. snd Julian is right that calcite has corrected FLOOR and CEIL functions in CALCITE-3412, Flink has upgraded calcite to 1.26 version which contains

Re: [Flink-SQL] FLOORing OR CEILing a DATE or TIMESTAMP to WEEK uses Thursdays as week start

2021-03-03 Thread Leonard Xu
Hi, Jaffe Flink follows old version calcite’s behaviour which lead to the wrong behavior. snd Julian is right that calcite has corrected FLOOR and CEIL functions in CALCITE-3412, Flink has upgraded calcite to 1.26 version which contains the patch, what we need is only to adapt it in Flink

Re: [Flink-SQL] FLOORing OR CEILing a DATE or TIMESTAMP to WEEK uses Thursdays as week start

2021-03-02 Thread Jaffe, Julian
Calcite does not follow ISO-8601. Instead, until very recently Calcite weeks started on Thursdays[1]. (As an aside, Calcite somewhat abuses the WEEK time unit - converting a date to a week returns an integer representing the week of the year the date falls in while FLOORing or CEILing a

Re: [Flink-SQL] FLOORing OR CEILing a DATE or TIMESTAMP to WEEK uses Thursdays as week start

2021-03-02 Thread Timo Walther
Hi Sebastián, it might be the case that some time functions are not correct due to the underlying refactoring of data structures. I will loop in Leonard in CC that currently works on improving this situation as part of FLIP-162 [1]. @Leonard: Is this wrong behavior on your list? Regards,

[Flink-SQL] FLOORing OR CEILing a DATE or TIMESTAMP to WEEK uses Thursdays as week start

2021-03-02 Thread Sebastián Magrí
While using a simple query such as this SELECT `ts`, FLOOR(`ts` TO WEEK) as `week_start`, CEIL(`ts` TO WEEK) as `week_end` FROM some_table I get some weird results like these: 2021-03-01T00:00|2021-02-25T00:00|2021-03-04T00:00 Which is obviously wrong since March 1st is on