Using custom Kafka timestamps

Use a timestamp field from the messages as the event time, and set your own column name and watermark interval. Do this when the time of the event differs from the time when Kafka received the record.

The input column must meet both requirements:

  • The type is long.
  • The value is an epoch time in milliseconds since January 1, 1970.
  1. In the Streaming SQL Console, click Projects in the left navigation pane, and click the name of your project.
    The project opens, with the Explorer panel on the left. To open the Streaming SQL Console, see Accessing Cloudera SQL Stream Builder.
  2. Open the Kafka table, and click the Event Time tab.
  3. Turn off Use Kafka Timestamps.
  4. In Input Timestamp Column, enter the column of the schema that holds the epoch time, for example tsColumn.
  5. In Event Time Column, enter the name of the new column, for example ets.
  6. In Watermark Seconds, enter the interval, for example 4.

Cloudera SQL Stream Builder (SSB) converts the input column with TO_TIMESTAMP_LTZ([***COLUMN***], 3). The generated DDL has the following form:

`ets` AS TO_TIMESTAMP_LTZ(`tsColumn`, 3),
WATERMARK FOR `ets` AS `ets` - INTERVAL '4' SECOND