Uploaded image for project: 'Flink'
  1. Flink
  2. FLINK-21617 FLIP-162: Consistent Flink SQL time function behavior
  3. FLINK-21624

Correct FLOOR/CEIL (TIMESTAMP/TIMESTAMP_LTZ/DATE TO WEEK) functions

    XMLWordPrintableJSON

Details

    Description

      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 Monday, February 25th is Thursday as well as March 04th.
       
      I've tried different combinations of timezone configurations and with both timestamps and dates, with the same results.
       
      Is there anything obviously wrong in that query? Is there any configuration to keep in mind for the start of week day?
       
      from user ML: http://apache-flink-user-mailing-list-archive.2336050.n4.nabble.com/Flink-SQL-FLOORing-OR-CEILing-a-DATE-or-TIMESTAMP-to-WEEK-uses-Thursdays-as-week-start-td41838.html

      Attachments

        Issue Links

          Activity

            People

              leonard Leonard Xu
              leonard Leonard Xu
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: