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

Correct function CURRENT_TIMESTAMP/CURRENT_TIME/CURRENT_DATE/LOCALTIME/LOCALTIMESTAMP/NOW()

    XMLWordPrintableJSON

    Details

    • Type: Sub-task
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 1.13.0
    • Component/s: Table SQL / API
    • Environment:
    • Release Note:
      Hide
      The value of time function CURRENT_TIMESTAMP and NOW() are corrected from UTC time with `TIMESTAMP` type to epoch time with `TIMESTAMP_LTZ` type. Time function LOCALTIME, LOCALTIMESTAMP, CURRENT_DATE, CURRENT_TIME, CURRENT_TIMESTAMP and NOW() are corrected from evaluates for per record in batch mode to evaluate once at query-start for batch job.
      Show
      The value of time function CURRENT_TIMESTAMP and NOW() are corrected from UTC time with `TIMESTAMP` type to epoch time with `TIMESTAMP_LTZ` type. Time function LOCALTIME, LOCALTIMESTAMP, CURRENT_DATE, CURRENT_TIME, CURRENT_TIMESTAMP and NOW() are corrected from evaluates for per record in batch mode to evaluate once at query-start for batch job.

      Description

      1. fix the return value type as well the return value for following time functions

       

      function existed problem current behavior proposed changes
      CURRENT_DATE returns UTC date, but user expects current date in session time zone return type: DATE
      #session timezone: UTC
      2020-12-28
      #session timezone: UTC+8
      2020-12-28
       return current date in session time zone, the return type should be DATE
      #session timezone: UTC
      2020-12-28
      #session timezone: UTC+8
      2020-12-29
      CURRENT_TIME returns UTC time, but user expects current time in session time zone return type:  TIME 
      #session timezone: UTC
      23:52:52
      #session timezone: UTC+8
      23:52:52
      return current time in session time zone, the return type should be TIME
      #session timezone: UTC
      23:52:52
      #session timezone: UTC+8
      07:52:52
      CURRENT_TIMESTAMP returns UTC timestamp, but user expects current timestamp in session time zone  
      return type:  TIMESTAMP
      #session timezone: UTC
      2020-12-28 23:52:52
      #session timezone: UTC+8
      2020-12-28 23:52:52
      return current timestamp in session time zone, the return type should be
      TIMESTAMP WITH LOCAL TIME ZONE
      #session timezone: UTC
      2020-12-28 23:52:52
      #session timezone: UTC+8
      2020-12-29 07:52:52
      NOW() returns UTC timestamp, but user expects current timestamp in session time zone  
      return type: TIMESTAMP
      #session timezone: UTC
      2020-12-28 23:52:52
      #session timezone: UTC+8
      2020-12-28 23:52:52
      return current timestamp in session time zone, the return type should be
      TIMESTAMP WITH LOCAL TIME ZONE
      #session timezone: UTC
      2020-12-28 23:52:52
      #session timezone: UTC+8
      2020-12-29 07:52:52

       

      2. The following functions' evaluation is depend on execution mode

      • LOCALTIME
      • LOCALTIMESTAMP
      • CURRENT_DATE
      • CURRENT_TIME
      • CURRENT_TIMESTAMP
      • NOW()

      Flink evaluates above time function values according to execution mode, i.e. Flink evaluates time function value for row level in Streaming mode, evaluates the time function value at query start for batch mode.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                Leonard Xu Leonard Xu
                Reporter:
                Leonard Xu Leonard Xu
              • Votes:
                0 Vote for this issue
                Watchers:
                4 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: