Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Due to the historical reason, we didn't not support TIME(9) yet, we think It's a good time point to support it in this FLIP.

8.

...

  Use execution mode to hint time function evaluation, introduce CURRENT_ROW_TIMESTAMP function.

For time functionsan option table.exec.time-function-evaluation to control the materialize time point of time function value. The time function includes

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

The default value of table.exec.time-function-evaluation includes 'auto', 'per-record', 'query-start'.

...

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.

...

For batch users who want to obtain row level timestamp of now, we introduce function CURRENT_ROW_TIMESTAMP, the function can also be used in streaming mode.

It's similar to  CURRENT_TIMESTAMP function, CURRENT_ROW_TIMESTAMP always returns current timestamp in session time zone, the return type should be TIMESTAMP WITH LOCAL TIME ZONE.

The difference is function CURRENT_ROW_TIMESTAMP always evaluates in row-level, but  function CURRENT_TIMESTAMP evaluates according to the execution mode.

General Implementations

1.

General Implementations

1.Change the codegen implementations for above five functions/cast conversions according to the value of introduced table option: table.exec.fallback-legacy-time-function

...

Will add plan tests, unit tests, window operator harness tests as well as IT tests

Future Plan

As a conservative plan, we don't introduce the config 'table.exec.time-function-evaluation' right now, but we has discussed that we should introduce it in the future once we received enough user requirements / feedbacks.

The option is used to control the materialize time point of time function value. The time function includes:

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

The default value of table.exec.time-function-evaluation includes 'auto', 'row', 'query-start'.

  • 'auto', the default value which means Flink evaluates above time function values according to execution mode, i.e. Flink evaluates time function value for per record in Streaming mode, evaluates the time function value at query start for batch mode.
  • 'row', Flink evaluates time function value for per record.
  • 'query-start', Flink evaluate above time function value at query-start, the time function always returns same value in a query

Rejected Alternatives

1. Change the return type of function CURRENT_TIMESTAMP/NOW()/PROCETIME() to TIMESTAMP WITH TIME ZONE. This proposal needs to introduce a new type TIMESTAMP WITH TIME ZONE, and we think there are no enough benefits. If we do this, the return type of function CURRENT_TIME must be TIME WITH TIME ZONE for consistent consideration, we need to introduce another type.

...