Search code examples
apache-flink

Flink TimeCharacteristic


I see in many older versions of Flink code a line that defines some time characteristic, like this: env.setStreamTimeCharacteristic(TimeCharacteristic.EventTime);

However, looking more into the documentation shows that this is now deprecated. Is it no longer required?


Solution

  • Setting the time characteristic is no longer required.

    To be honest, it never did very much. The time characteristic established whether a TimeWindow would be an event-time or processing-time window; setting the time characteristic to ingestion time arranged for timestamps and watermarks that were automatically generated; and a few other minor details. A few API changes made the time characteristic completely unnecessary (mostly the introduction of the new WatermarkStrategy interface).

    Quoting from the Flink 1.12 release notes:

    In Flink 1.12 the default stream time characteristic has been changed to EventTime, thus you don’t need to call this method for enabling event-time support anymore. Explicitly using processing-time windows and timers works in event-time mode. If you need to disable watermarks, please use ExecutionConfig.setAutoWatermarkInterval(long). If you are using IngestionTime, please manually set an appropriate WatermarkStrategy. If you are using generic “time window” operations (for example KeyedStream.timeWindow()) that change behaviour based on the time characteristic, please use equivalent operations that explicitly specify processing time or event time.